List of usage examples for java.awt.geom Rectangle2D getY
public abstract double getY();
From source file:com.igormaznitsa.sciareto.ui.editors.MMDEditor.java
public void topicToCentre(@Nullable final Topic topic) { if (topic != null) { SwingUtilities.invokeLater(new Runnable() { @Override//from w w w .j a va2s. c o m public void run() { final AbstractElement element = (AbstractElement) Assertions.assertNotNull(topic).getPayload(); if (element != null) { final Rectangle2D bounds = element.getBounds(); final Dimension viewPortSize = getViewport().getExtentSize(); final int x = Math.max(0, (int) Math .round(bounds.getX() - (viewPortSize.getWidth() - bounds.getWidth()) / 2)); final int y = Math.max(0, (int) Math .round(bounds.getY() - (viewPortSize.getHeight() - bounds.getHeight()) / 2)); getViewport().setViewPosition(new Point(x, y)); } } }); } }
From source file:at.tuwien.ifs.somtoolbox.visualization.thematicmap.SOMRegion.java
public void fillRegion(Graphics2D g, boolean chessboard) { if (!resolved) { fillcolor = getColor(mainClass.classIndex); Color c = repairColor(fillcolor); g.setColor(c);// w w w . java 2 s . c om if (segments.isEmpty()) { return; } g.fillPolygon(this); } else { if (chessboard) { if (polygons == null) { // calculate polygons polygons = new ArrayList<Polygon>(); Rectangle2D rect = getBounds2D(); double w = rect.getWidth(); double h = rect.getHeight(); if (h > 200 || w > 200) { Logger.getLogger("at.tuwien.ifs.somtoolbox").info("ERROR: h>200 || w>200"); return; } int x = (int) rect.getX(); int y = (int) rect.getY(); int xSteps = (int) (w / (int) Grid.SIZE); int ySteps = (int) (h / (int) Grid.SIZE); // int n = classes.size(); for (int i = 0; i < xSteps; i++) { for (int j = 0; j < ySteps; j++) { Polygon p = new Polygon(); p.addPoint((int) (x + i * Grid.SIZE), (int) (y + j * Grid.SIZE)); p.addPoint((int) (x + i * Grid.SIZE + Grid.SIZE), (int) (y + j * Grid.SIZE)); p.addPoint((int) (x + i * Grid.SIZE + Grid.SIZE), (int) (y + Grid.SIZE + j * Grid.SIZE)); p.addPoint((int) (x + i * Grid.SIZE), (int) (y + Grid.SIZE + j * Grid.SIZE)); if (!this.contains(p.getBounds())) { continue; } SOMClass clss = indexGenerator.getNextIndex(); g.setColor(getColor(clss.classIndex)); g.fillPolygon(p); polygons.add(p); } } } else { // use pre-calculated polygons for (int i = 0; i < polygons.size(); i++) { SOMClass clss = indexGenerator.getNextIndex(); g.setColor(getColor(clss.classIndex)); Polygon p = polygons.get(i); g.fillPolygon(p); } } } else { for (int i = 0; i < grids.size(); i++) { Grid grid = grids.get(i); if (grid.clss == null) { continue; } g.setColor(getColor(grid.clss.classIndex)); g.fillRect((int) grid.topLeft.coord(0), (int) grid.topLeft.coord(1), (int) Grid.SIZE, (int) Grid.SIZE); } } } }
From source file:de.iteratec.iteraplan.businesslogic.exchange.visio.informationflow.VisioInformationFlowExport.java
private void setTitlePos(Rectangle2D graphAreaBounds, Shape title, List<Shape> queryInfo) { double titleTopY = graphAreaBounds.getY() + graphAreaBounds.getHeight() + DISTANCE_TO_MARGIN_INCHES * 2.8 + title.getHeight() + getQueryInfoHeight(queryInfo); setTitlePosAndSize(title, graphAreaBounds.getX(), titleTopY, null); }
From source file:figs.treeVisualization.gui.PhyloDateAxis.java
/** * Translates the data value to the display coordinates (Java 2D User Space) * of the chart./*from ww w. ja v a 2 s. com*/ * * @param value the date to be plotted. * @param area the rectangle (in Java2D space) where the data is to be * plotted. * @param edge the axis location. * * @return The coordinate corresponding to the supplied data value. * * Original method is in <code>org.jfree.chart.axis.DateAxis</code> */ @Override public double valueToJava2D(double value, Rectangle2D area, RectangleEdge edge) { Timeline timeline = this.getTimeline(); value = timeline.toTimelineValue((long) value); DateRange range = (DateRange) getRange(); double axisMin = timeline.toTimelineValue(range.getLowerDate()); double axisMax = timeline.toTimelineValue(range.getUpperDate()); double result = 0.0; if (RectangleEdge.isTopOrBottom(edge)) { double minX = area.getX(); double maxX = area.getMaxX(); if (isInverted()) { result = maxX + ((value - axisMin) / (axisMax - axisMin)) * (minX - maxX); } else { result = minX + ((value - axisMin) / (axisMax - axisMin)) * (maxX - minX); } } else if (RectangleEdge.isLeftOrRight(edge)) { //double minY = area.getMinY(); //double maxY = area.getMaxY(); double minY = area.getY(); double maxY = area.getHeight(); if (isInverted()) { result = minY + (((value - axisMin) / (axisMax - axisMin)) * (maxY - minY)); } else { result = maxY - (((value - axisMin) / (axisMax - axisMin)) * (maxY - minY)); } } return result; }
From source file:de.iteratec.iteraplan.businesslogic.exchange.visio.informationflow.VisioInformationFlowExport.java
private void createNamesLegend(Rectangle2D legendsBox) throws MasterNotFoundException { double frameX = legendsBox.getX(); double frameY = legendsBox.getY() - getTargetPage().getHeight() + MARGIN_IN; double frameWidth = legendsBox.getWidth(); double frameHeight = getTargetPage().getHeight() - legendsBox.getHeight() - DISTANCE_TO_MARGIN_INCHES; createNamesLegend(frameX, frameY, frameWidth, frameHeight, informationFlowOptions.isNakedExport(), MessageAccess.getStringOrNull("graphicalExport.informationflow.title", getLocale())); }
From source file:com.newatlanta.bluedragon.CategoryAxis.java
public AxisSpace reserveSpace(Graphics2D g2, Plot plot, Rectangle2D plotArea, RectangleEdge edge, AxisSpace space) {//w ww. j a v a 2 s . co m // create a new space object if one wasn't supplied... if (space == null) { space = new AxisSpace(); } // if the axis is not visible, no additional space is required... if (!isVisible()) { return space; } // calculate the max size of the tick labels (if visible)... double tickLabelHeight = 0.0; double tickLabelWidth = 0.0; if (isTickLabelsVisible()) { g2.setFont(getTickLabelFont()); AxisState state = new AxisState(); // we call refresh ticks just to get the maximum width or height if (RectangleEdge.isTopOrBottom(edge)) { // BEGIN fix for category labels that wrap // If space has been reserved to the left and right then we need to // reduce the plot area // by this amount so that the space needed by category labels that wrap // on to multiple lines // will be calculated properly. Rectangle2D newPlotArea = new Rectangle2D.Double(plotArea.getX(), plotArea.getY(), plotArea.getWidth() - space.getLeft() - space.getRight(), plotArea.getHeight()); refreshTicks(g2, state, newPlotArea, edge); // END fix for category labels that wrap } else { refreshTicks(g2, state, plotArea, edge); } if (edge == RectangleEdge.TOP) { tickLabelHeight = state.getMax(); } else if (edge == RectangleEdge.BOTTOM) { tickLabelHeight = state.getMax(); } else if (edge == RectangleEdge.LEFT) { tickLabelWidth = state.getMax(); } else if (edge == RectangleEdge.RIGHT) { tickLabelWidth = state.getMax(); } } // get the axis label size and update the space object... Rectangle2D labelEnclosure = getLabelEnclosure(g2, edge); double labelHeight = 0.0; double labelWidth = 0.0; if (RectangleEdge.isTopOrBottom(edge)) { labelHeight = labelEnclosure.getHeight(); space.add(labelHeight + tickLabelHeight + this.getCategoryLabelPositionOffset(), edge); } else if (RectangleEdge.isLeftOrRight(edge)) { labelWidth = labelEnclosure.getWidth(); space.add(labelWidth + tickLabelWidth + this.getCategoryLabelPositionOffset(), edge); } return space; }
From source file:savant.view.tracks.BAMTrackRenderer.java
private void renderSNPMode(Graphics2D g2, GraphPaneAdapter gp, Resolution r) throws RenderingException { Genome genome = GenomeController.getInstance().getGenome(); if (!genome.isSequenceSet()) { throw new RenderingException("No reference sequence loaded\nSwitch to standard display mode", RenderingException.WARNING_PRIORITY); }/* w w w .ja v a 2s .c o m*/ AxisRange axisRange = (AxisRange) instructions.get(DrawingInstruction.AXIS_RANGE); ColourScheme cs = (ColourScheme) instructions.get(DrawingInstruction.COLOUR_SCHEME); List<Pileup> pileups = new ArrayList<Pileup>(); // make the pileups int length = axisRange.getXMax() - axisRange.getXMin() + 1; assert Math.abs(axisRange.getXMin()) <= Integer.MAX_VALUE; int startPosition = (int) axisRange.getXMin(); for (int j = 0; j < length; j++) { pileups.add(new Pileup(startPosition + j)); } // Go through the samrecords and edit the pileups for (Record record : data) { SAMRecord samRecord = ((BAMIntervalRecord) record).getSAMRecord(); updatePileupsFromSAMRecord(pileups, samRecord, startPosition); } double maxHeight = 0; for (Pileup p : pileups) { int current = p.getTotalCoverage(null); if (current > maxHeight) { maxHeight = current; } } gp.setXRange(axisRange.getXRange()); gp.setYRange(new Range(0, (int) Math.rint((double) maxHeight / 0.9))); double unitHeight = (Math.rint(gp.transformYPos(0) * 0.9)) / maxHeight; double unitWidth = gp.getUnitWidth(); ColourAccumulator accumulator = new ColourAccumulator(cs); List<Rectangle2D> insertions = new ArrayList<Rectangle2D>(); for (Pileup p : pileups) { int totalCoverage = p.getTotalCoverage(null); if (totalCoverage > 0) { double bottom = gp.transformYPos(0); double x = gp.transformXPos(p.getPosition()); VariantType genomeNuc = VariantType.fromChar((char) refSeq[p.getPosition() - startPosition]); VariantType snpNuc = genomeNuc; // Only record a shape if we have at least some mismatches. if (totalCoverage > p.getCoverage(genomeNuc, null)) { // Reduce height for insertions, since they don't contribute to the height. double h = unitHeight * (totalCoverage - p.getCoverage(VariantType.INSERTION, null)); recordToShapeMap.put(new PileupRecord(p, false), new Rectangle2D.Double(x, bottom - h, unitWidth, h)); } while ((genome.isSequenceSet() && (snpNuc = p.getLargestVariantType(genomeNuc)) != null) || ((snpNuc = p.getLargestVariantType(VariantType.OTHER)) != null)) { double h = unitHeight * p.getCoverage(snpNuc, null); Rectangle2D rect = new Rectangle2D.Double(x, bottom - h, unitWidth, h); accumulator.addShape(getSubPileColour(snpNuc, genomeNuc), rect); if (snpNuc == VariantType.INSERTION) { insertions.add(rect); } else { bottom -= h; } p.clearVariantType(snpNuc); } } } accumulator.fill(g2); for (Rectangle2D ins : insertions) { drawInsertion(g2, ins.getX(), ins.getY(), ins.getWidth(), ins.getHeight()); } }
From source file:org.tsho.dmc2.core.chart.AbsorbingAreaRenderer.java
public void render(final Graphics2D g2, final Rectangle2D dataArea, final PlotRenderingInfo info) { state = STATE_RUNNING;/* w w w. j a v a2s . com*/ gridWidth = (int) dataArea.getWidth(); gridHeight = (int) dataArea.getHeight(); //imageX,imageY correspond to point(0,0) int imageX = (int) dataArea.getX() + 1; int imageY = (int) dataArea.getY() + 1; DataBufferInt dataBuffer; image = new BufferedImage(gridWidth, gridHeight, BufferedImage.TYPE_INT_RGB); WritableRaster raster = image.getRaster(); grid = ((DataBufferInt) raster.getDataBuffer()).getData(); ValueAxis domainAxis = plot.getDomainAxis(); ValueAxis rangeAxis = plot.getRangeAxis(); xEpsilon = Math.abs((domainAxis.getUpperBound() - domainAxis.getLowerBound()) / (double) gridWidth); yEpsilon = Math.abs((rangeAxis.getUpperBound() - rangeAxis.getLowerBound()) / (double) gridHeight); int numPoints = gridHeight * gridWidth; int index = 0; int rate = numPoints / 100; if (justClearedSet) { if (criticalSetFound) { this.clearDisplay(); g2.drawImage(image, null, imageX, imageY); } justClearedSet = false; return; } if (!notYetRendered) { plotCopiedDisplay(); g2.drawImage(image, null, imageX, imageY); } notYetRendered = false; if (criticalSetFound && !findCriticalSetAgain) { if (this.chooseSegmentsSet) chooseSegments(g2, image, imageX, imageY); if (this.plotAttractorSet) plotAttractor(g2, image, imageX, imageY); if (this.iterateChosenSegmentsSet) iterateChosenSegments(g2, image, imageX, imageY); if (this.hideAttractorSet) hideAttractor(g2, image, imageX, imageY); } else { this.disableAllActionsExceptStop(); det = new AbsorbingAreaRenderer.ImplicitDeterminant(gridWidth, gridHeight, epsilon, g2, image, imageX, imageY); gridBackup = new int[grid.length]; copyDisplay(); criticalSetFound = true; findCriticalSetAgain = false; g2.drawImage(image, null, imageX, imageY); this.enableAllActionsExceptStop(); } }
From source file:org.apache.fop.render.ps.PSRenderer.java
/** * {@inheritDoc}/* w ww .j a v a 2 s .c o m*/ */ protected void startVParea(CTM ctm, Rectangle2D clippingRect) { saveGraphicsState(); if (clippingRect != null) { clipRect((float) clippingRect.getX() / 1000f, (float) clippingRect.getY() / 1000f, (float) clippingRect.getWidth() / 1000f, (float) clippingRect.getHeight() / 1000f); } // multiply with current CTM final double[] matrix = ctm.toArray(); matrix[4] /= 1000f; matrix[5] /= 1000f; concatMatrix(matrix); }
From source file:savant.view.tracks.BAMTrackRenderer.java
private void renderStrandSNPMode(Graphics2D g2, GraphPaneAdapter gp, Resolution r) throws RenderingException { Genome genome = GenomeController.getInstance().getGenome(); if (!genome.isSequenceSet()) { throw new RenderingException("No reference sequence loaded\nSwitch to standard display mode", RenderingException.WARNING_PRIORITY); }//from w w w . java2 s.co m AxisRange axisRange = (AxisRange) instructions.get(DrawingInstruction.AXIS_RANGE); int xMin = axisRange.getXMin(); int xMax = axisRange.getXMax(); ColourScheme cs = (ColourScheme) instructions.get(DrawingInstruction.COLOUR_SCHEME); List<Pileup> pileups = new ArrayList<Pileup>(); // make the pileups for (int j = xMin; j <= xMax; j++) { pileups.add(new Pileup(j)); } // Go through the samrecords and edit the pileups for (Record record : data) { SAMRecord samRecord = ((BAMIntervalRecord) record).getSAMRecord(); updatePileupsFromSAMRecord(pileups, samRecord, xMin); } double maxHeight = 0.0; for (Pileup p : pileups) { int current1 = p.getTotalCoverage(Strand.REVERSE); int current2 = p.getTotalCoverage(Strand.FORWARD); if (current1 > maxHeight) { maxHeight = current1; } if (current2 > maxHeight) { maxHeight = current2; } } int yMax = (int) Math.ceil(maxHeight / 0.9); gp.setYRange(new Range(-yMax, yMax)); instructions.put(DrawingInstruction.AXIS_RANGE, new AxisRange(xMin, xMax, -yMax, yMax)); ColourAccumulator accumulator = new ColourAccumulator(cs); List<Rectangle2D> insertions = new ArrayList<Rectangle2D>(); double unitHeight = gp.getUnitHeight(); double unitWidth = gp.getUnitWidth(); double axis = gp.transformYPos(0.0); for (Pileup p : pileups) { if (p.getTotalCoverage(null) > 0) { VariantType snpNuc = null; double bottom = axis; double top = axis; double x = gp.transformXPos(p.getPosition()); VariantType genomeNuc = null; if (genome.isSequenceSet()) { genomeNuc = VariantType.fromChar((char) refSeq[p.getPosition() - xMin]); snpNuc = genomeNuc; } // Only record a shape if we have at least some mismatches. int totalCoverage = p.getTotalCoverage(null); if (totalCoverage > p.getCoverage(genomeNuc, null)) { double h = unitHeight * (totalCoverage - p.getCoverage(VariantType.INSERTION, null)); recordToShapeMap .put(new PileupRecord(p, true), new Rectangle2D.Double(x, bottom - unitHeight * (p.getTotalCoverage(Strand.FORWARD) - p.getCoverage(VariantType.INSERTION, Strand.FORWARD)), unitWidth, h)); } while ((genome.isSequenceSet() && (snpNuc = p.getLargestVariantType(genomeNuc)) != null) || ((snpNuc = p.getLargestVariantType(null)) != null)) { int forwardCoverage = p.getCoverage(snpNuc, Strand.FORWARD); int reverseCoverage = p.getCoverage(snpNuc, Strand.REVERSE); ColourKey col = getSubPileColour(snpNuc, genomeNuc); if (forwardCoverage > 0) { double h = unitHeight * forwardCoverage; Rectangle2D rect = new Rectangle2D.Double(x, bottom - h, unitWidth, h); accumulator.addShape(col == ColourKey.REVERSE_STRAND ? ColourKey.FORWARD_STRAND : col, rect); if (snpNuc == VariantType.INSERTION) { insertions.add(rect); } else { bottom -= h; } } if (reverseCoverage > 0) { double h = unitHeight * reverseCoverage; Rectangle2D rect = new Rectangle2D.Double(x, top, unitWidth, h); accumulator.addShape(col, rect); if (snpNuc == VariantType.INSERTION) { insertions.add(rect); } else { top += h; } } p.clearVariantType(snpNuc); } } } accumulator.fill(g2); for (Rectangle2D ins : insertions) { drawInsertion(g2, ins.getX(), ins.getY(), ins.getWidth(), ins.getHeight()); } g2.setColor(Color.BLACK); g2.draw(new Line2D.Double(0, axis, gp.getWidth(), axis)); }