List of usage examples for java.awt.geom Rectangle2D getHeight
public abstract double getHeight();
From source file:org.logisticPlanning.utils.graphics.chart.impl.jfree._JFCLineChart2D.java
/** * paint a legend/* w w w .j a v a 2 s .co m*/ * * @param legend * the legend * @param graphics * the graphics * @param bounds * the bounds */ private static final void __paintLegend(final LegendTitle legend, final Graphics2D graphics, final Rectangle2D bounds) { final Rectangle2D titleArea; final BlockParams p; final double ww, hh; final RectangleConstraint constraint; final Size2D size; p = new BlockParams(); p.setGenerateEntities(false); ww = bounds.getWidth(); if (ww <= 0.0d) { return; } hh = bounds.getHeight(); if (hh <= 0.0d) { return; } constraint = new RectangleConstraint(ww, new Range(0.0, ww), LengthConstraintType.RANGE, hh, new Range(0.0, hh), LengthConstraintType.RANGE); size = legend.arrange(graphics, constraint); titleArea = _JFCLineChart2D.__createAlignedRectangle2D(size, bounds, legend.getHorizontalAlignment(), VerticalAlignment.TOP); legend.setMargin(_JFCLineChart2D.LEGEND_MARGIN); legend.setPadding(_JFCLineChart2D.CHART_INSETS); legend.draw(graphics, titleArea, p); }
From source file:org.uva.itast.blended.omr.OMRUtils.java
private static void searchMarkSquare(OMRProcessor omr, PageImage pageImage, Field field, boolean medianfilter) { Rectangle2D bbox = field.getBBox();// milimeters // leemos la anchura de las marcas en milmetros double markWidth = Math.max(1, bbox.getWidth()); double markHeight = Math.max(1, bbox.getHeight()); SolidSquareMarkScanner markScanner = new SolidSquareMarkScanner(omr, pageImage, markWidth, markHeight, medianfilter);/*ww w . ja v a2s . co m*/ if (logger.isDebugEnabled()) { logger.debug("searchMarkCircle - field name=" + field.getName() + " at position:" + field.getBBox()); //$NON-NLS-1$ } searchMark(pageImage, field, markScanner); }
From source file:org.uva.itast.blended.omr.OMRUtils.java
/** * Mtodo que busca marcas de tipo circle en un objeto tipo Gray8Image * //from w w w . ja v a 2 s . co m * @param i * * @param field * @param markedImage * @param mark * @param markedImage * @param field * @param medianfilter */ private static void searchMarkCircle(OMRProcessor omr, PageImage pageImage, Field field, boolean medianfilter) { Rectangle2D bbox = field.getBBox();// milimeters // leemos la anchura de las marcas en milmetros double markWidth = Math.max(1, bbox.getWidth()); double markHeight = Math.max(1, bbox.getHeight()); SolidCircleMarkScanner markScanner = new SolidCircleMarkScanner(omr, pageImage, markWidth, markHeight, medianfilter); if (logger.isDebugEnabled()) { logger.debug( "START searchMarkCircle - field name=" + field.getName() + " at position:" + field.getBBox()); //$NON-NLS-1$ } searchMark(pageImage, field, markScanner); }
From source file:net.sf.mzmine.chartbasics.ChartLogicsFX.java
/** * /* w ww . j a va2s .c o m*/ * Domain and Range axes need to share the same unit (e.g. mm) * * @param myChart * @return */ public static double calcWidthToHeight(ChartViewer myChart, double chartHeight) { makeChartResizable(myChart); myChart.getCanvas().draw(); XYPlot plot = (XYPlot) myChart.getChart().getPlot(); ChartRenderingInfo info = myChart.getRenderingInfo(); Rectangle2D dataArea = info.getPlotInfo().getDataArea(); Rectangle2D chartArea = info.getChartArea(); // calc title space: will be added later to the right plot size double titleWidth = chartArea.getWidth() - dataArea.getWidth(); double titleHeight = chartArea.getHeight() - dataArea.getHeight(); // calc right plot size with axis dim. // real plot width is given by factor; double realPH = chartHeight - titleHeight; // ranges ValueAxis domainAxis = plot.getDomainAxis(); org.jfree.data.Range x = domainAxis.getRange(); ValueAxis rangeAxis = plot.getRangeAxis(); org.jfree.data.Range y = rangeAxis.getRange(); // real plot height can be calculated by double realPW = realPH / y.getLength() * x.getLength(); double width = realPW + titleWidth; return width; }
From source file:net.sf.mzmine.chartbasics.ChartLogics.java
/** * //www . j av a2 s . com * Domain and Range axes need to share the same unit (e.g. mm) * * @param myChart * @return */ public static double calcWidthToHeight(ChartPanel myChart, double chartHeight) { makeChartResizable(myChart); // paint on a ghost panel JPanel parent = (JPanel) myChart.getParent(); JPanel p = new JPanel(); p.removeAll(); p.add(myChart, BorderLayout.CENTER); p.setBounds(myChart.getBounds()); myChart.paintImmediately(myChart.getBounds()); p.removeAll(); parent.add(myChart); XYPlot plot = (XYPlot) myChart.getChart().getPlot(); ChartRenderingInfo info = myChart.getChartRenderingInfo(); Rectangle2D dataArea = info.getPlotInfo().getDataArea(); Rectangle2D chartArea = info.getChartArea(); // calc title space: will be added later to the right plot size double titleWidth = chartArea.getWidth() - dataArea.getWidth(); double titleHeight = chartArea.getHeight() - dataArea.getHeight(); // calc right plot size with axis dim. // real plot width is given by factor; double realPH = chartHeight - titleHeight; // ranges ValueAxis domainAxis = plot.getDomainAxis(); org.jfree.data.Range x = domainAxis.getRange(); ValueAxis rangeAxis = plot.getRangeAxis(); org.jfree.data.Range y = rangeAxis.getRange(); // real plot height can be calculated by double realPW = realPH / y.getLength() * x.getLength(); double width = realPW + titleWidth; return width; }
From source file:net.sf.mzmine.chartbasics.ChartLogicsFX.java
/** * Returns dimensions for limiting factor width or height * /*from w w w .java 2 s. c o m*/ * @param myChart * @return */ public static Dimension calcMaxSize(ChartViewer myChart, double chartWidth, double chartHeight) { makeChartResizable(myChart); // paint on a ghost panel myChart.getCanvas().draw(); XYPlot plot = (XYPlot) myChart.getChart().getPlot(); ChartRenderingInfo info = myChart.getRenderingInfo(); Rectangle2D dataArea = info.getPlotInfo().getDataArea(); Rectangle2D chartArea = info.getChartArea(); // calc title space: will be added later to the right plot size double titleWidth = chartArea.getWidth() - dataArea.getWidth(); double titleHeight = chartArea.getHeight() - dataArea.getHeight(); // calculatig width for max height // calc right plot size with axis dim. // real plot width is given by factor; double realPH = chartHeight - titleHeight; // ranges ValueAxis domainAxis = plot.getDomainAxis(); org.jfree.data.Range x = domainAxis.getRange(); ValueAxis rangeAxis = plot.getRangeAxis(); org.jfree.data.Range y = rangeAxis.getRange(); // real plot height can be calculated by double realPW = realPH / y.getLength() * x.getLength(); double width = realPW + titleWidth; // if width is higher than given chartWidth then calc height for chartWidth if (width > chartWidth) { // calc right plot size with axis dim. // real plot width is given by factor; realPW = chartWidth - titleWidth; // real plot height can be calculated by realPH = realPW / x.getLength() * y.getLength(); double height = realPH + titleHeight; // Return size return new Dimension((int) chartWidth, (int) height); } else { // Return size return new Dimension((int) width, (int) chartHeight); } }
From source file:com.t_oster.visicut.misc.Helper.java
/** * Returns a rectangle (parralel to x and y axis), which contains * the given rectangle after the given transform. If the transform * contains a rotation, the resulting rectangle is the smallest bounding-box * @param src// w w w . j a va 2 s. co m * @param at * @return */ public static Rectangle2D transform(Rectangle2D src, AffineTransform at) { if (at == null) { return src; } else { java.awt.Point.Double[] points = new java.awt.Point.Double[4]; points[0] = new java.awt.Point.Double(src.getX(), src.getY()); points[1] = new java.awt.Point.Double(src.getX(), src.getY() + src.getHeight()); points[2] = new java.awt.Point.Double(src.getX() + src.getWidth(), src.getY()); points[3] = new java.awt.Point.Double(src.getX() + src.getWidth(), src.getY() + src.getHeight()); for (int i = 0; i < 4; i++) { at.transform(points[i], points[i]); } return smallestBoundingBox(points); } }
From source file:net.sf.mzmine.chartbasics.ChartLogics.java
/** * Returns dimensions for limiting factor width or height * /*from w w w . ja v a 2s . c om*/ * @param myChart * @return */ public static Dimension calcMaxSize(ChartPanel myChart, double chartWidth, double chartHeight) { makeChartResizable(myChart); // paint on a ghost panel JPanel parent = (JPanel) myChart.getParent(); JPanel p = new JPanel(); p.removeAll(); p.add(myChart, BorderLayout.CENTER); p.setBounds(myChart.getBounds()); myChart.paintImmediately(myChart.getBounds()); p.removeAll(); parent.add(myChart); XYPlot plot = (XYPlot) myChart.getChart().getPlot(); ChartRenderingInfo info = myChart.getChartRenderingInfo(); Rectangle2D dataArea = info.getPlotInfo().getDataArea(); Rectangle2D chartArea = info.getChartArea(); // calc title space: will be added later to the right plot size double titleWidth = chartArea.getWidth() - dataArea.getWidth(); double titleHeight = chartArea.getHeight() - dataArea.getHeight(); // calculatig width for max height // calc right plot size with axis dim. // real plot width is given by factor; double realPH = chartHeight - titleHeight; // ranges ValueAxis domainAxis = plot.getDomainAxis(); org.jfree.data.Range x = domainAxis.getRange(); ValueAxis rangeAxis = plot.getRangeAxis(); org.jfree.data.Range y = rangeAxis.getRange(); // real plot height can be calculated by double realPW = realPH / y.getLength() * x.getLength(); double width = realPW + titleWidth; // if width is higher than given chartWidth then calc height for chartWidth if (width > chartWidth) { // calc right plot size with axis dim. // real plot width is given by factor; realPW = chartWidth - titleWidth; // real plot height can be calculated by realPH = realPW / x.getLength() * y.getLength(); double height = realPH + titleHeight; // Return size return new Dimension((int) chartWidth, (int) height); } else { // Return size return new Dimension((int) width, (int) chartHeight); } }
From source file:org.apache.xmlgraphics.ps.PSImageUtils.java
/** * Generates commands to modify the current transformation matrix so an image fits * into a given rectangle.// w w w . ja v a 2s . c om * @param gen the PostScript generator * @param imageDimensions the image's dimensions * @param targetRect the target rectangle * @throws IOException if an I/O error occurs */ public static void translateAndScale(PSGenerator gen, Dimension2D imageDimensions, Rectangle2D targetRect) throws IOException { gen.writeln(gen.formatDouble(targetRect.getX()) + " " + gen.formatDouble(targetRect.getY()) + " translate"); if (imageDimensions == null) { imageDimensions = new Dimension(1, 1); } double sx = targetRect.getWidth() / imageDimensions.getWidth(); double sy = targetRect.getHeight() / imageDimensions.getHeight(); if (sx != 1 || sy != 1) { gen.writeln(gen.formatDouble(sx) + " " + gen.formatDouble(sy) + " scale"); } }
From source file:net.sf.mzmine.chartbasics.ChartLogicsFX.java
/** * calculates the correct height with multiple iterations Domain and Range axes need to share the * same unit (e.g. mm)/* ww w . j av a 2 s.c o m*/ * * @param myChart * @param dataWidth width of data * @param axis for width calculation * @return */ public static double calcHeightToWidth(ChartViewer myChart, double chartWidth, double estimatedHeight, int iterations) { // if(myChart.getChartRenderingInfo()==null || // myChart.getChartRenderingInfo().getChartArea()==null || // myChart.getChartRenderingInfo().getChartArea().getWidth()==0) // result double height = estimatedHeight; double lastH = height; makeChartResizable(myChart); try { for (int i = 0; i < iterations; i++) { // paint on ghost panel with estimated height (if copy panel==true) myChart.getCanvas().setWidth((int) chartWidth); myChart.getCanvas().setHeight((int) estimatedHeight); myChart.getCanvas().draw(); XYPlot plot = (XYPlot) myChart.getChart().getPlot(); ChartRenderingInfo info = myChart.getRenderingInfo(); Rectangle2D dataArea = info.getPlotInfo().getDataArea(); Rectangle2D chartArea = info.getChartArea(); // calc title space: will be added later to the right plot size double titleWidth = chartArea.getWidth() - dataArea.getWidth(); double titleHeight = chartArea.getHeight() - dataArea.getHeight(); // calc right plot size with axis dim. // real plot width is given by factor; double realPW = chartWidth - titleWidth; // ranges ValueAxis domainAxis = plot.getDomainAxis(); org.jfree.data.Range x = domainAxis.getRange(); ValueAxis rangeAxis = plot.getRangeAxis(); org.jfree.data.Range y = rangeAxis.getRange(); // real plot height can be calculated by double realPH = realPW / x.getLength() * y.getLength(); // the real height height = realPH + titleHeight; // for next iteration estimatedHeight = height; if ((int) lastH == (int) height) break; else lastH = height; } } catch (Exception ex) { ex.printStackTrace(); } return height; }