FR [ 2539927 ] Display Zoom combobox

https://sourceforge.net/tracker/?func=detail&atid=879335&aid=2539927&group_id=176962
This commit is contained in:
teo_sarca 2009-05-18 09:20:26 +00:00
parent d5b93419a2
commit 905b55ff0c
3 changed files with 116 additions and 40 deletions

View File

@ -1,8 +1,27 @@
<?xml version="1.0" encoding="UTF-8"?>
<project-modules id="moduleCoreId" project-version="1.5.0">
<wb-module deploy-name="Adempiere_trunk">
<wb-resource deploy-path="/" source-path="/zkwebui"/>
<property name="java-output-path" value="build/classes"/>
<property name="context-root" value="webui"/>
</wb-module>
</project-modules>
<?xml version="1.0" encoding="UTF-8"?>
<project-modules id="moduleCoreId" project-version="1.5.0">
<wb-module deploy-name="Adempiere_trunk">
<wb-resource deploy-path="/" source-path="/zkwebui"/>
<wb-resource deploy-path="/WEB-INF/classes" source-path="/base/src"/>
<wb-resource deploy-path="/WEB-INF/classes" source-path="/glassfishfacet/src"/>
<wb-resource deploy-path="/WEB-INF/classes" source-path="/jbossfacet/src"/>
<wb-resource deploy-path="/WEB-INF/classes" source-path="/client/src"/>
<wb-resource deploy-path="/WEB-INF/classes" source-path="/sqlj/src"/>
<wb-resource deploy-path="/WEB-INF/classes" source-path="/install/src"/>
<wb-resource deploy-path="/WEB-INF/classes" source-path="/extend/src"/>
<wb-resource deploy-path="/WEB-INF/classes" source-path="/serverRoot/src/main/ejb"/>
<wb-resource deploy-path="/WEB-INF/classes" source-path="/serverRoot/src/main/server"/>
<wb-resource deploy-path="/WEB-INF/classes" source-path="/serverRoot/src/main/servlet"/>
<wb-resource deploy-path="/WEB-INF/classes" source-path="/interfaces/src"/>
<wb-resource deploy-path="/WEB-INF/classes" source-path="/serverApps/src/main/servlet"/>
<wb-resource deploy-path="/WEB-INF/classes" source-path="/zkwebui/WEB-INF/src"/>
<wb-resource deploy-path="/WEB-INF/classes" source-path="/JasperReports/src"/>
<wb-resource deploy-path="/WEB-INF/classes" source-path="/JasperReportsWebApp/src"/>
<wb-resource deploy-path="/WEB-INF/classes" source-path="/tools/src"/>
<wb-resource deploy-path="/WEB-INF/classes" source-path="/webCM/src/main/servlet"/>
<wb-resource deploy-path="/WEB-INF/classes" source-path="/migration/src"/>
<wb-resource deploy-path="/WEB-INF/classes" source-path="/posterita/posterita/src/main"/>
<property name="java-output-path" value="build/classes"/>
<property name="context-root" value="webui"/>
</wb-module>
</project-modules>

View File

@ -22,6 +22,7 @@ import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Point;
import java.awt.Rectangle;
import java.util.HashMap;
import org.compiere.model.MQuery;
import org.compiere.print.layout.LayoutEngine;
@ -34,13 +35,17 @@ import org.compiere.util.CLogger;
*
* @author Jorg Janke
* @version $Id: View.java,v 1.2 2006/07/30 00:53:02 jjanke Exp $
*
* @author Teo Sarca, www.arhipac.ro
* <li>FR [ 2539927 ] Display Zoom combobox
* https://sourceforge.net/tracker/?func=detail&atid=879335&aid=2539927&group_id=176962
*/
public class View extends CPanel
{
/**
*
*/
private static final long serialVersionUID = 851611162566661576L;
private static final long serialVersionUID = 5640892952739279088L;
/**
* Print Preview
@ -56,10 +61,18 @@ public class View extends CPanel
/** Zoom Level */
private int m_zoomLevel = 0;
private int m_zoomLevel = 2;
/** Zoom Options */
public static final String[] ZOOM_OPTIONS = new String[]
{"100%", "75%", "50%"};
public static final String[] ZOOM_OPTIONS = new String[] {"200%", "150%", "100%", "75%", "50%"};
private static HashMap<String, Double> ZOOM_ScaleValues = new HashMap<String, Double>();
static {
ZOOM_ScaleValues.put("200%", 2.00);
ZOOM_ScaleValues.put("150%", 1.50);
ZOOM_ScaleValues.put("100%", 1.00);
ZOOM_ScaleValues.put("75%", 0.75);
ZOOM_ScaleValues.put("50%", 0.50);
}
/** Margin around paper */
public static int MARGIN = 5;
/** Margin Background Color */
@ -70,6 +83,12 @@ public class View extends CPanel
/*************************************************************************/
public int getMarginSize(boolean doScale)
{
double scale = (doScale ? getScale() : 1.00);
return (int)(MARGIN * scale);
}
/**
* Minimum Size
* @return Max Page Size
@ -85,8 +104,8 @@ public class View extends CPanel
*/
public Dimension getMaximumSize()
{
return new Dimension (getPaperWidth()+(2*MARGIN),
(getPaperHeight()+MARGIN)*getPageCount()+MARGIN);
return new Dimension (getPaperWidth()+(2*getMarginSize(true)),
(getPaperHeight()+getMarginSize(true))*getPageCount()+getMarginSize(true));
} // getMaximumSize
/**
@ -115,6 +134,7 @@ public class View extends CPanel
{
// log.fine( "View.paintComponent", g.getClip());
Graphics2D g2D = (Graphics2D)g;
g2D.scale(getScale(), getScale());
Rectangle bounds = g2D.getClipBounds();
//
g2D.setColor(COLOR_BACKGROUND);
@ -123,7 +143,7 @@ public class View extends CPanel
// for all pages
for (int page = 0; page < m_layout.getPages().size(); page++)
{
Rectangle pageRectangle = getRectangleOfPage(page+1);
Rectangle pageRectangle = getRectangleOfPage(page+1, false);
if (bounds.intersects(pageRectangle))
{
Page p = (Page)m_layout.getPages().get(page);
@ -153,7 +173,7 @@ public class View extends CPanel
{
if (ZOOM_OPTIONS[i].equals(levelString))
{
m_zoomLevel = i;
setZoomLevel(i);
break;
}
}
@ -167,6 +187,15 @@ public class View extends CPanel
{
return m_zoomLevel;
} // getZoomLevel
private double getScale()
{
Double scale = ZOOM_ScaleValues.get(ZOOM_OPTIONS[m_zoomLevel]);
if (scale != null)
return scale.doubleValue();
else
return 1.00;
}
/**
* Get Rectange of Page
@ -175,10 +204,18 @@ public class View extends CPanel
*/
public Rectangle getRectangleOfPage(int pageNo)
{
int y = MARGIN + ((pageNo-1) * (getPaperHeight() + MARGIN));
return new Rectangle (MARGIN, y, getPaperWidth(), getPaperHeight());
return getRectangleOfPage(pageNo, true);
// int y = (int)(MARGIN + ((pageNo-1) * (getPaperHeight() + MARGIN)));
// return new Rectangle (MARGIN, y, getPaperWidth(), getPaperHeight());
} // getRectangleOfPage
public Rectangle getRectangleOfPage(int pageNo, boolean doScale)
{
System.out.println("height: "+getPaperHeight(false)+"->"+getPaperHeight(true));
System.out.println("width: "+getPaperWidth(false)+"->"+getPaperWidth(true));
int y = (int)(getMarginSize(doScale) + ((pageNo-1) * (getPaperHeight(doScale) + getMarginSize(doScale))));
return new Rectangle (getMarginSize(doScale), y, getPaperWidth(doScale), getPaperHeight(doScale));
} // getRectangleOfPage
/**
* Get Page at Point
@ -187,8 +224,8 @@ public class View extends CPanel
*/
public float getPageNoAt (Point p)
{
float y = p.y;
float pageHeight = getPaperHeight() + MARGIN;
float y = (float)(p.y / getScale());
float pageHeight = getPaperHeight(false) + getMarginSize(false);
return 1f + (y/pageHeight);
} // getPageAt
@ -235,7 +272,14 @@ public class View extends CPanel
*/
public int getPaperHeight()
{
return (int)m_layout.getPaper().getHeight(true);
return getPaperHeight(true);
// return (int)(m_layout.getPaper().getHeight(true) * getScale());
} // getPaperHeight
public int getPaperHeight(boolean doScale)
{
double scale = (doScale ? getScale() : 1.0);
return (int)(m_layout.getPaper().getHeight(true) * scale);
} // getPaperHeight
/**
@ -244,7 +288,14 @@ public class View extends CPanel
*/
public int getPaperWidth()
{
return (int)m_layout.getPaper().getWidth(true);
return getPaperWidth(true);
// return (int)(m_layout.getPaper().getWidth(true) * getScale());
} // getPaperHeight
public int getPaperWidth(boolean doScale)
{
double scale = (doScale ? getScale() : 1.0);
return (int)(m_layout.getPaper().getWidth(true) * scale);
} // getPaperHeight
/**
@ -255,9 +306,11 @@ public class View extends CPanel
public MQuery getDrillDown (Point absolutePoint)
{
int pageNo = (int)getPageNoAt(absolutePoint);
Rectangle pageRectangle = getRectangleOfPage(pageNo);
Point relativePoint = new Point (absolutePoint.x-pageRectangle.x,
absolutePoint.y-pageRectangle.y);
Rectangle pageRectangle = getRectangleOfPage(pageNo, false);
Point relativePoint = new Point (
(int)(absolutePoint.x/getScale()-pageRectangle.x),
(int)(absolutePoint.y/getScale()-pageRectangle.y)
);
Page page = (Page)m_layout.getPages().get(pageNo-1);
//
log.config("Relative=" + relativePoint + ", " + page);
@ -277,8 +330,10 @@ public class View extends CPanel
{
int pageNo = (int)getPageNoAt(absolutePoint);
Rectangle pageRectangle = getRectangleOfPage(pageNo);
Point relativePoint = new Point (absolutePoint.x-pageRectangle.x,
absolutePoint.y-pageRectangle.y);
Point relativePoint = new Point (
(int)(absolutePoint.x/getScale()-pageRectangle.x),
(int)(absolutePoint.y/getScale()-pageRectangle.y)
);
Page page = (Page)m_layout.getPages().get(pageNo-1);
//
log.config("Relative=" + relativePoint + ", " + page);

View File

@ -115,6 +115,8 @@ import org.compiere.util.ValueNamePair;
* <li>FR [ 1779403 ] Report Viewer: add PgUp and PgDown key handlers
* <li>BF [ 1836908 ] Report customize NPE when no window access
* <li>FR [ 1894640 ] Report Engine: Excel Export support
* <li>FR [ 2539927 ] Display Zoom combobox
* https://sourceforge.net/tracker/?func=detail&atid=879335&aid=2539927&group_id=176962
* @author victor.perez@e-evolution.com
* <li>FR [ 1966328 ] New Window Info to MRP and CRP into View http://sourceforge.net/tracker/index.php?func=detail&aid=1966328&group_id=176962&atid=879335
* <li>FR [ 2011569 ] Implementing new Summary flag in Report View http://sourceforge.net/tracker/index.php?func=detail&aid=2011569&group_id=176962&atid=879335
@ -216,7 +218,7 @@ public class Viewer extends CFrame
private CComboBox comboDrill = new CComboBox();
//FR 201156
private CCheckBox summary = new CCheckBox();
// private CComboBox comboZoom = new CComboBox(View.ZOOM_OPTIONS);
private CComboBox comboZoom = new CComboBox(View.ZOOM_OPTIONS);
/**
@ -269,8 +271,8 @@ public class Viewer extends CFrame
// Zoom Level
toolBar.addSeparator();
// toolBar.add(comboZoom, null);
// comboZoom.setToolTipText(Msg.getMsg(m_ctx, "Zoom"));
toolBar.add(comboZoom, null);
comboZoom.setToolTipText(Msg.getMsg(m_ctx, "Zoom"));
// Drill
toolBar.addSeparator();
labelDrill.setText(Msg.getMsg(m_ctx, "Drill") + ": ");
@ -313,7 +315,8 @@ public class Viewer extends CFrame
private void dynInit()
{
createMenu();
// comboZoom.addActionListener(this);
comboZoom.setSelectedIndex(m_viewPanel.getZoomLevel());
comboZoom.addActionListener(this);
// Change Listener to set Page no
//pb comment this out so that scrolling works normally
//centerScrollPane.getViewport().addChangeListener(this);
@ -454,8 +457,8 @@ public class Viewer extends CFrame
centerScrollPane.setPreferredSize(new Dimension
(m_viewPanel.getPaperWidth()+30, m_viewPanel.getPaperHeight()+15));
centerScrollPane.getViewport().setViewSize(new Dimension
(m_viewPanel.getPaperWidth()+2*View.MARGIN,
m_viewPanel.getPaperHeight()+2*View.MARGIN));
(m_viewPanel.getPaperWidth()+2*m_viewPanel.getMarginSize(true),
m_viewPanel.getPaperHeight()+2*m_viewPanel.getMarginSize(true)));
// Report Info
setTitle(Msg.getMsg(m_ctx, "Report") + ": " + m_reportEngine.getName() + " " + Env.getHeader(m_ctx, 0));
@ -651,10 +654,9 @@ public class Viewer extends CFrame
log.config(cmd);
this.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
//
// if (e.getSource() == comboZoom)
// cmd_zoom();
// else
if (e.getSource() == comboReport)
if (e.getSource() == comboZoom)
cmd_zoom();
else if (e.getSource() == comboReport)
cmd_report();
else if (e.getSource() == comboDrill)
cmd_drill();
@ -744,8 +746,8 @@ public class Viewer extends CFrame
bNext.setEnabled (m_pageNo != m_pageMax);
//
Rectangle pageRectangle = m_viewPanel.getRectangleOfPage(m_pageNo);
pageRectangle.x -= View.MARGIN;
pageRectangle.y -= View.MARGIN;
pageRectangle.x -= m_viewPanel.getMarginSize(true);
pageRectangle.y -= m_viewPanel.getMarginSize(true);
centerScrollPane.getViewport().setViewPosition(pageRectangle.getLocation());
// System.out.println("scrollTo " + pageRectangle);
@ -1212,7 +1214,7 @@ public class Viewer extends CFrame
private void cmd_zoom()
{
setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
// m_viewPanel.setZoomLevel(comboZoom.getSelectedIndex());
m_viewPanel.setZoomLevel(comboZoom.getSelectedIndex());
revalidate();
cmd_drill(); // setCursor
} // cmd_zoom