List of usage examples for java.awt Graphics2D fillRect
public abstract void fillRect(int x, int y, int width, int height);
From source file:coolmap.canvas.datarenderer.renderer.impl.NumberToColor.java
@Override public void renderCellLD(Double v, VNode rowNode, VNode columnNode, Graphics2D g2D, int anchorX, int anchorY, int cellWidth, int cellHeight) { // renderCellSD(v, rowNode, columnNode, g2D, anchorX, anchorY, cellWidth, cellHeight); if (v == null || v.isNaN()) { //System.out.println(v); _markNull(v, rowNode, columnNode, g2D, anchorX, anchorY, cellWidth, cellHeight); } else {//w w w. j a va 2 s .c o m try { int index = (int) ((v - _minValue) / (_maxValue - _minValue) * _gradientColors.length); if (index >= _gradientColors.length) { index = _gradientColors.length - 1; } if (index < 0) { index = 0; } Color c = _gradientColors[index]; //System.out.println(c); g2D.setColor(c); // System.out.println((int) cellWidth + " " + ((int) cellHeight)) ; g2D.fillRect((int) anchorX, (int) anchorY, (int) cellWidth, (int) cellHeight); } catch (Exception e) { } } }
From source file:coolmap.canvas.datarenderer.renderer.impl.NumberToColor.java
@Override public void renderCellSD(Double v, VNode rowNode, VNode columnNode, Graphics2D g2D, int anchorX, int anchorY, int cellWidth, int cellHeight) { if (v == null || v.isNaN()) { //System.out.println(v); _markNull(v, rowNode, columnNode, g2D, anchorX, anchorY, cellWidth, cellHeight); } else {//from w w w. ja v a 2 s.c o m try { int index = (int) ((v - _minValue) / (_maxValue - _minValue) * _gradientColors.length); if (index >= _gradientColors.length) { index = _gradientColors.length - 1; } if (index < 0) { index = 0; } Color c = _gradientColors[index]; //System.out.println(c); g2D.setColor(c); // System.out.println((int) cellWidth + " " + ((int) cellHeight)) ; g2D.fillRect((int) anchorX, (int) anchorY, (int) cellWidth, (int) cellHeight); // System.out.println("WH:" + cellWidth + " " + cellHeight); if (drawSubMap.isSelected()) { //paint the sub heatmap block // System.out.println("draw submap"); if (rowNode == null || columnNode == null || rowNode.isSingleNode() && columnNode.isSingleNode()) { return; } else { //need to determine the number of cMatrices CoolMapObject object = getCoolMapObject(); List<CMatrix> matrices = object.getBaseCMatrices(); Double value; //row and column indices Integer[] rowIndices; Integer[] colIndices; //whether they are group node or node if (rowNode.isGroupNode()) { rowIndices = rowNode.getBaseIndicesFromCOntology( (CMatrix) object.getBaseCMatrices().get(0), COntology.ROW); } else { rowIndices = new Integer[] { ((CMatrix) object.getBaseCMatrices().get(0)) .getIndexOfRowName(rowNode.getName()) }; } if (columnNode.isGroupNode()) { colIndices = columnNode.getBaseIndicesFromCOntology( (CMatrix) object.getBaseCMatrices().get(0), COntology.COLUMN); } else { colIndices = new Integer[] { ((CMatrix) object.getBaseCMatrices().get(0)) .getIndexOfColName(columnNode.getName()) }; } //then determine the width int subMatrixWidth = Math.round(cellWidth * 1.0f / matrices.size()); int subAnchorX = anchorX; int subCellHeight = Math.round(cellHeight * 1.0f / rowIndices.length); int subCellWidth = Math.round(subMatrixWidth * 1.0f / colIndices.length); // System.out.println("CW:" + cellWidth + " " + colIndices.length + " " + subCellWidth); // System.out.println("CH:" + cellHeight + " " + rowIndices.length + " " + subCellHeight); if (subCellHeight < 1) { subCellHeight = 1; } if (subCellWidth < 1) { subCellWidth = 1; } for (CMatrix matrix : matrices) { int rowIndex = 0; for (Integer i : rowIndices) { if (i == null || i < 0) { continue; } int columnIndex = 0; for (Integer j : colIndices) { if (j == null || j < 0) { continue; } try { value = (Double) matrix.getValue(i, j); index = (int) ((value - _minValue) / (_maxValue - _minValue) * _gradientColors.length); if (index >= _gradientColors.length) { index = _gradientColors.length - 1; } if (index < 0) { index = 0; } c = _gradientColors[index]; g2D.setColor(c); int subCellX = Math .round(subMatrixWidth * 1.0f * columnIndex / colIndices.length) + subAnchorX; int subCellY = Math.round(cellHeight * 1.0f * rowIndex / rowIndices.length) + anchorY; // System.out.println("WTF:" + columnIndex + " " + rowIndex + "----" + subCellX + " " + subCellY + " " + subCellWidth + " " + subCellHeight); g2D.fillRect(subCellX, subCellY, subCellWidth, subCellHeight); } catch (Exception e) { //draw it here e.printStackTrace(); } columnIndex++; } //end of column loop rowIndex++; } //end of row loop subAnchorX += subMatrixWidth; } //end of matrix loop g2D.setStroke(UI.stroke1); g2D.setColor(Color.BLACK); g2D.drawRect(anchorX, anchorY, cellWidth, cellHeight); } } } catch (Exception e) { // System.out.println("Null pointer exception:" + v + "," + _minValue + "," + _maxValue + "," + _gradientColors + " " + getName() + "" + this); //e.printStackTrace(); } } }
From source file:org.broad.igv.renderer.SpliceJunctionRenderer.java
/** * Draw a filled arc representing a single feature. The thickness and height of the arc are proportional to the * depth of coverage. Some of this gets a bit arcane -- the result of lots of visual tweaking. * * @param pixelFeatureStart the starting position of the feature, whether on-screen or not * @param pixelFeatureEnd the ending position of the feature, whether on-screen or not * @param pixelJunctionStart the starting position of the junction, whether on-screen or not * @param pixelJunctionEnd the ending position of the junction, whether on-screen or not * @param depth coverage depth * @param trackRectangle/*from www .j a va 2s . com*/ * @param context * @param strand * @param junctionFeature * @param shouldHighlight * @param featureColor the color specified for this feature. May be null. */ protected void drawFeature(int pixelFeatureStart, int pixelFeatureEnd, int pixelJunctionStart, int pixelJunctionEnd, float depth, Rectangle trackRectangle, RenderContext context, Strand strand, SpliceJunctionFeature junctionFeature, boolean shouldHighlight, Color featureColor, boolean shouldShowFlankingRegions) { boolean isPositiveStrand = true; // Get the feature's direction, color appropriately if (strand != null && strand.equals(Strand.NEGATIVE)) isPositiveStrand = false; //If the feature color is specified, use it, except that we set our own alpha depending on whether //the feature is highlighted. Otherwise default based on strand and highlight. Color color; if (featureColor != null) { int r = featureColor.getRed(); int g = featureColor.getGreen(); int b = featureColor.getBlue(); int alpha = shouldHighlight ? 255 : 140; color = new Color(r, g, b, alpha); } else { if (isPositiveStrand) color = shouldHighlight ? ARC_COLOR_HIGHLIGHT_POS : ARC_COLOR_POS; else color = shouldHighlight ? ARC_COLOR_HIGHLIGHT_NEG : ARC_COLOR_NEG; } Graphics2D g2D = context.getGraphic2DForColor(color); if (PreferenceManager.getInstance().getAsBoolean(PreferenceManager.ENABLE_ANTIALISING)) { g2D.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); g2D.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON); } //Height of top of an arc of maximum depth int maxPossibleArcHeight = (trackRectangle.height - 1) / 2; if (shouldShowFlankingRegions) { if (junctionFeature.hasFlankingRegionDepthArrays()) { //draw a wigglegram of the splice junction flanking region depth of coverage int startFlankingRegionPixelLength = pixelJunctionStart - pixelFeatureStart; int endFlankingRegionPixelLength = pixelFeatureEnd - pixelJunctionEnd; drawFlankingRegion(g2D, pixelFeatureStart, startFlankingRegionPixelLength, junctionFeature.getStartFlankingRegionDepthArray(), maxPossibleArcHeight, trackRectangle, isPositiveStrand); drawFlankingRegion(g2D, pixelJunctionEnd + 1, endFlankingRegionPixelLength, junctionFeature.getEndFlankingRegionDepthArray(), maxPossibleArcHeight, trackRectangle, isPositiveStrand); } else { //Draw rectangles indicating the overlap on each side of the junction int overlapRectHeight = 3; int overlapRectTopX = (int) trackRectangle.getCenterY() + (isPositiveStrand ? -2 : 0); if (pixelFeatureStart < pixelJunctionStart) { g2D.fillRect(pixelFeatureStart, overlapRectTopX, pixelJunctionStart - pixelFeatureStart, overlapRectHeight); } if (pixelJunctionEnd < pixelFeatureEnd) { g2D.fillRect(pixelJunctionEnd, overlapRectTopX, pixelFeatureEnd - pixelJunctionEnd, overlapRectHeight); } } } //Create a path describing the arc, using Bezier curves. The Bezier control points for the top and //bottom arcs are based on the boundary points of the rectangles containing the arcs //proportion of the maximum arc height used by a minimum-height arc double minArcHeightProportion = 0.33; int innerArcHeight = (int) (maxPossibleArcHeight * minArcHeightProportion); float depthProportionOfMax = Math.min(1, depth / maxDepth); int arcWidth = Math.max(1, (int) ((1 - minArcHeightProportion) * maxPossibleArcHeight * depthProportionOfMax)); int outerArcHeight = innerArcHeight + arcWidth; //Height of bottom of the arc int arcBeginY = (int) trackRectangle.getCenterY() + (isPositiveStrand ? -1 : 1); int outerArcPeakY = isPositiveStrand ? arcBeginY - outerArcHeight : arcBeginY + outerArcHeight; int innerArcPeakY = isPositiveStrand ? arcBeginY - innerArcHeight : arcBeginY + innerArcHeight; //dhmay: I don't really understand Bezier curves. For some reason I have to put the Bezier control //points farther up or down than I want the arcs to extend. This multiplier seems about right int outerBezierY = arcBeginY + (int) (1.3 * (outerArcPeakY - arcBeginY)); int innerBezierY = arcBeginY + (int) (1.3 * (innerArcPeakY - arcBeginY)); //Putting the Bezier control points slightly off to the sides of the arc int bezierXPad = Math.max(1, (pixelJunctionEnd - pixelJunctionStart) / 30); GeneralPath arcPath = new GeneralPath(); arcPath.moveTo(pixelJunctionStart, arcBeginY); arcPath.curveTo(pixelJunctionStart - bezierXPad, outerBezierY, //Bezier 1 pixelJunctionEnd + bezierXPad, outerBezierY, //Bezier 2 pixelJunctionEnd, arcBeginY); //Arc end arcPath.curveTo(pixelJunctionEnd + bezierXPad, innerBezierY, //Bezier 1 pixelJunctionStart - bezierXPad, innerBezierY, //Bezier 2 pixelJunctionStart, arcBeginY); //Arc end //Draw the arc, to ensure outline is drawn completely (fill won't do it, necessarily). This will also //give the arc a darker outline g2D.draw(arcPath); //Fill the arc g2D.fill(arcPath); g2D.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_DEFAULT); g2D.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_DEFAULT); }
From source file:gov.sandia.umf.platform.ui.jobs.Raster.java
public JFreeChart createChart(final XYDataset dataset) { final JFreeChart chart = ChartFactory.createScatterPlot(null, // chart title null, // x axis label null, // y axis label dataset, // data PlotOrientation.VERTICAL, false, // include legend true, // tooltips false // urls );/*from w w w . j av a 2 s . com*/ chart.setBackgroundPaint(Color.white); XYPlot plot = chart.getXYPlot(); plot.setBackgroundPaint(Color.white); plot.setRangeGridlinePaint(Color.lightGray); plot.setDomainPannable(true); plot.setRangePannable(true); plot.setRenderer(new XYDotRenderer() { public void drawItem(java.awt.Graphics2D g2, XYItemRendererState state, java.awt.geom.Rectangle2D dataArea, PlotRenderingInfo info, XYPlot plot, ValueAxis domainAxis, ValueAxis rangeAxis, XYDataset dataset, int series, int item, CrosshairState crosshairState, int pass) { // Copied from org.jfree.chart.renderer.xy.XYDotRenderer.java and modified. // This would only need to be a couple of lines if they authors of jfreechart had not made dotWidth and dotHeight private members. // Yet another example of textbook OO programming gone awry. (Can anyone hear me scream?) if (!getItemVisible(series, item)) return; int dotWidth = 1; double rasterLines = rangeAxis.getRange().getLength(); int pixels = g2.getClipBounds().height; double height = pixels / rasterLines; if (height > 10) height -= 2; else if (height > 2) height -= 1; int dotHeight = (int) Math.min(20, Math.max(1, Math.floor(height))); double x = dataset.getXValue(series, item); double y = dataset.getYValue(series, item); if (Double.isNaN(y)) return; double adjx = (dotWidth - 1) / 2.0; double adjy = (dotHeight - 1) / 2.0; RectangleEdge xAxisLocation = plot.getDomainAxisEdge(); RectangleEdge yAxisLocation = plot.getRangeAxisEdge(); double transX = domainAxis.valueToJava2D(x, dataArea, xAxisLocation) - adjx; double transY = rangeAxis.valueToJava2D(y, dataArea, yAxisLocation) - adjy; g2.setPaint(Color.black); PlotOrientation orientation = plot.getOrientation(); if (orientation == PlotOrientation.HORIZONTAL) g2.fillRect((int) transY, (int) transX, dotHeight, dotWidth); else g2.fillRect((int) transX, (int) transY, dotWidth, dotHeight); int domainAxisIndex = plot.getDomainAxisIndex(domainAxis); int rangeAxisIndex = plot.getRangeAxisIndex(rangeAxis); updateCrosshairValues(crosshairState, x, y, domainAxisIndex, rangeAxisIndex, transX, transY, orientation); } }); NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); // Integer units only return chart; }
From source file:org.broad.igv.variant.VariantTrack.java
private boolean colorBand(Graphics2D g2D, Rectangle bandRectangle, Rectangle visibleRectangle, boolean coloredLast, Rectangle textRectangle, List<String> sampleList, BackgroundType type) { boolean supressFill = (getDisplayMode() == DisplayMode.SQUISHED && squishedHeight < 4); for (String sample : sampleList) { if (coloredLast) { g2D.setColor(BAND1_COLOR);/*from w w w.ja va 2 s . com*/ coloredLast = false; } else { g2D.setColor(BAND2_COLOR); coloredLast = true; } if (bandRectangle.intersects(visibleRectangle)) { if (!supressFill) { if (selectedSamples.contains(sample) && hasAlignmentFiles()) { g2D.setColor(SELECTED_BAND_COLOR); } g2D.fillRect(bandRectangle.x, bandRectangle.y, bandRectangle.width, bandRectangle.height); } if (type == BackgroundType.NAME) { sampleBounds .add(new SampleBounds(bandRectangle.y, bandRectangle.y + bandRectangle.height, sample)); if (bandRectangle.height >= 3) { String printName = sample; textRectangle.y = bandRectangle.y + 1; g2D.setColor(Color.black); GraphicUtils.drawWrappedText(printName, bandRectangle, g2D, false); } } else if (type == BackgroundType.ATTRIBUTE) { } } bandRectangle.y += bandRectangle.height; } return coloredLast; }
From source file:net.rptools.maptool.client.ui.ChatTypingNotification.java
/** * This component is only made visible when there are notifications to be displayed. That means the first couple of * IF statements in this method are redundant since paintComponent() will not be called unless the component is * visible, and it will only be visible when there are notifications... *//*from w ww . ja v a 2 s.c o m*/ @Override protected void paintComponent(Graphics g) { // System.out.println("Chat panel is painting itself..."); if (AppPreferences.getTypingNotificationDuration() == 0) { return; } LinkedMap chatTypers = MapTool.getFrame().getChatNotificationTimers().getChatTypers(); if (chatTypers == null || chatTypers.isEmpty()) { return; } Boolean showBackground = AppPreferences.getChatNotificationShowBackground(); Graphics2D statsG = (Graphics2D) g.create(); Font boldFont = AppStyle.labelFont.deriveFont(Font.BOLD); Font font = AppStyle.labelFont; FontMetrics valueFM = g.getFontMetrics(font); FontMetrics keyFM = g.getFontMetrics(boldFont); int PADDING7 = 7; int PADDING3 = 3; int PADDING2 = 2; BufferedImage img = AppStyle.panelTexture; int rowHeight = Math.max(valueFM.getHeight(), keyFM.getHeight()); setBorder(null); int width = AppStyle.miniMapBorder.getRightMargin() + AppStyle.miniMapBorder.getLeftMargin(); int height = getHeight() - PADDING2 + AppStyle.miniMapBorder.getTopMargin() + AppStyle.miniMapBorder.getBottomMargin(); statsG.setFont(font); SwingUtil.useAntiAliasing(statsG); Rectangle bounds = new Rectangle(AppStyle.miniMapBorder.getLeftMargin(), height - getHeight() - AppStyle.miniMapBorder.getTopMargin(), getWidth() - width, getHeight() - AppStyle.miniMapBorder.getBottomMargin() - AppStyle.miniMapBorder.getTopMargin() + PADDING2); int y = bounds.y + rowHeight; rowHeight = Math.max(rowHeight, AppStyle.chatImage.getHeight()); setSize(getWidth(), ((chatTypers.size() * (PADDING3 + rowHeight)) + AppStyle.miniMapBorder.getTopMargin() + AppStyle.miniMapBorder.getBottomMargin())); if (showBackground) { g.drawImage(img, 0, 0, getWidth(), getHeight() + PADDING7, this); AppStyle.miniMapBorder.paintAround(statsG, bounds); } Rectangle rightRow = new Rectangle(AppStyle.miniMapBorder.getLeftMargin() + PADDING7, AppStyle.miniMapBorder.getTopMargin() + PADDING7, AppStyle.chatImage.getWidth(), AppStyle.chatImage.getHeight()); Set<?> keySet = chatTypers.keySet(); @SuppressWarnings("unchecked") Set<String> playerTimers = (Set<String>) keySet; for (String playerNamer : playerTimers) { if (showBackground) { statsG.setColor(new Color(249, 241, 230, 140)); statsG.fillRect(bounds.x + PADDING3, y - keyFM.getAscent(), (bounds.width - PADDING7 / 2) - PADDING3, rowHeight); statsG.setColor(new Color(175, 163, 149)); statsG.drawRect(bounds.x + PADDING3, y - keyFM.getAscent(), (bounds.width - PADDING7 / 2) - PADDING3, rowHeight); } g.drawImage(AppStyle.chatImage, bounds.x + 5, y - keyFM.getAscent(), (int) rightRow.getWidth(), (int) rightRow.getHeight(), this); // Values statsG.setColor(MapTool.getFrame().getChatTypingLabelColor()); statsG.setFont(boldFont); statsG.drawString(I18N.getText("msg.commandPanel.liveTyping", playerNamer), bounds.x + AppStyle.chatImage.getWidth() + PADDING7 * 2, y + 5); y += PADDING2 + rowHeight; } if (showBackground) { AppStyle.shadowBorder.paintWithin(statsG, bounds); } else { setOpaque(false); } }
From source file:org.openmicroscopy.shoola.agents.imviewer.util.saver.ImgSaver.java
/** * Saves the displayed images. /* ww w . jav a 2s . c o m*/ * * @param init Pass <code>true</code> to initialize the images to save, * <code>false</code> otherwise. */ void saveImage(boolean init) { if (ImViewerAgent.hasOpenGLSupport()) { saveAsTexture(); return; } UserNotifier un = ImViewerAgent.getRegistry().getUserNotifier(); if (init) createImages(uiDelegate.getSavingType()); //Builds the image to display. boolean unitBar = model.isUnitBar(); String v = getUnitBarValue(); int s = (int) getUnitBarSize(); boolean constrain; try { String name = uiDelegate.getSelectedFilePath(); // make sure the parent directory paths all exist FileUtils.forceMkdir(new File(name).getParentFile()); if (imageComponents == null) { constrain = unitBar && v != null && s < mainImage.getWidth() && imageType == ImgSaverUI.IMAGE; writeSingleImage(mainImage, constrain, name); } else { if (mainImage == null) return; Iterator i; int h, w; BufferedImage newImage; Graphics2D g2; if (uiDelegate.isSaveImagesInSeparatedFiles()) { constrain = unitBar && v != null && s < mainImage.getWidth() && imageType == ImgSaverUI.IMAGE; writeSingleImage(mainImage, constrain, name); i = imageComponents.iterator(); int j = 0; while (i.hasNext()) { constrain = unitBar && v != null && imageType != ImgSaverUI.LENS_IMAGE_AND_COMPONENTS; writeSingleImage((BufferedImage) i.next(), constrain, name + "_" + j); j++; } } else { int width = mainImage.getWidth(); h = mainImage.getHeight(); int n = imageComponents.size(); w = width * (n + 1) + ImgSaverPreviewer.SPACE * (n - 1); newImage = new BufferedImage(w, h, BufferedImage.TYPE_INT_RGB); g2 = (Graphics2D) newImage.getGraphics(); g2.setColor(Color.WHITE); ImagePaintingFactory.setGraphicRenderingSettings(g2); //Paint the original image. i = imageComponents.iterator(); int x = 0; while (i.hasNext()) { g2.drawImage((BufferedImage) i.next(), null, x, 0); if (unitBar && v != null && imageType != ImgSaverUI.LENS_IMAGE_AND_COMPONENTS) ImagePaintingFactory.paintScaleBar(g2, x + width - s - 10, h - 10, s, v); x += width; g2.fillRect(x, 0, ImgSaverPreviewer.SPACE, h); x += ImgSaverPreviewer.SPACE; } g2.drawImage(mainImage, null, x, 0); if (unitBar && v != null && !(imageType == ImgSaverUI.LENS_IMAGE_AND_COMPONENTS || imageType == ImgSaverUI.LENS_IMAGE)) ImagePaintingFactory.paintScaleBar(g2, x + width - s - 10, h - 10, s, v); writeImage(newImage, name); } } } catch (Exception e) { un.notifyInfo("Saving Image", "An error occurred while saving " + "the image."); return; } notifySave(getExtendedName(uiDelegate.getSelectedFilePath(), format)); if (uiDelegate.isSetDefaultFolder()) UIUtilities.setDefaultFolder(uiDelegate.getCurrentDirectory()); }
From source file:org.proteosuite.FastScatterPlot.java
/** * Draws a representation of the data within the dataArea region. The * <code>info</code> and <code>crosshairState</code> arguments may be * <code>null</code>.//from w w w. j a v a 2 s. c om * * @param g2 the graphics device. * @param dataArea the region in which the data is to be drawn. * @param info an optional object for collection dimension information. * @param crosshairState collects crosshair information (<code>null</code> * permitted). */ public void render(Graphics2D g2, Rectangle2D dataArea, PlotRenderingInfo info, CrosshairState crosshairState) { //long start = System.currentTimeMillis(); //System.out.println("Start: " + start); g2.setPaint(this.paint); // if the axes use a linear scale, you can uncomment the code below and // switch to the alternative transX/transY calculation inside the loop // that follows - it is a little bit faster then. // // int xx = (int) dataArea.getMinX(); // int ww = (int) dataArea.getWidth(); // int yy = (int) dataArea.getMaxY(); // int hh = (int) dataArea.getHeight(); // double domainMin = this.domainAxis.getLowerBound(); // double domainLength = this.domainAxis.getUpperBound() - domainMin; // double rangeMin = this.rangeAxis.getLowerBound(); // double rangeLength = this.rangeAxis.getUpperBound() - rangeMin; if (this.data != null) { for (int i = 0; i < this.data[0].length; i++) { float x = this.data[0][i]; float y = this.data[1][i]; //int transX = (int) (xx + ww * (x - domainMin) / domainLength); //int transY = (int) (yy - hh * (y - rangeMin) / rangeLength); int transX = (int) this.domainAxis.valueToJava2D(x, dataArea, RectangleEdge.BOTTOM); int transY = (int) this.rangeAxis.valueToJava2D(y, dataArea, RectangleEdge.LEFT); g2.fillRect(transX, transY, 1, 1); } } //long finish = System.currentTimeMillis(); //System.out.println("Finish: " + finish); //System.out.println("Time: " + (finish - start)); }
From source file:MyJava3D.java
public Graphics2D createGraphics2D(int width, int height, BufferedImage bi, Graphics g) { Graphics2D g2 = null; if (bi != null) { g2 = bi.createGraphics();/*from ww w . j a v a 2s .c o m*/ } else { g2 = (Graphics2D) g; } g2.setBackground(getBackground()); g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, AntiAlias); g2.setRenderingHint(RenderingHints.KEY_RENDERING, Rendering); if (clearSurface || clearOnce) { g2.clearRect(0, 0, width, height); clearOnce = false; } if (texture != null) { // set composite to opaque for texture fills g2.setComposite(AlphaComposite.SrcOver); g2.setPaint(texture); g2.fillRect(0, 0, width, height); } if (composite != null) { g2.setComposite(composite); } return g2; }
From source file:jhplot.HChart.java
public void drawToGraphics2D(Graphics2D g, int width, int height) { // self.chartCoordsMap = {} #Maps a chart to its raw screen coords, used // for converting coords g.setColor(Color.white);//from w ww .j a v a2s . com g.fillRect(0, 0, width, height); // // int boxWidth = width / this.chartarray[0].length; // int boxHeight = height / this.chartarray.length; int cols = N1final; int rows = N2final; int boxWidth = width / cols; int boxHeight = height / rows; // // # print "boxWidth ", boxWidth // # print "boxHeight ", boxHeight // for (int row = 0; row < chartarray.length; row++) int currentChartIndex = 0; for (int i2 = 0; i2 < rows; i2++) { for (int i1 = 0; i1 < cols; i1++) { currentChartIndex++; if (chart[i1][i2] != null) { int rowsUsed = 1; int colsUsed = 1; int chartX = boxWidth * i1; int chartY = boxHeight * i2; int chartwidth = boxWidth; int chartheight = boxHeight; // #Get Horizontalspace // for (int c = col; c > -1; c--) // { // // for c in range(col, -1, -1): // // if self.chartArray[row][c] == None: // if(this.chartarray[row][c] == null) // rowsUsed++; // // // rowsUsed = rowsUsed + 1 // // #print "adding row" // } chartwidth = boxWidth * rowsUsed; chartheight = boxHeight; chartX = chartX - (rowsUsed - 1) * boxWidth; // // # chart.configureDomainAxes() // # chart.configureRangeAxes() // // #Testing axes ranges not updated // from org.jfree.chart.event import PlotChangeEvent // chart[i1][i2].plotChanged(new // PlotChangeEvent(chart[i1][i2].getXYPlot())); chart[i1][i2].plotChanged(new PlotChangeEvent(chart[i1][i2].getPlot())); // ChartRenderingInfo info = new ChartRenderingInfo(); // chart[i1][i2].draw(g, new java.awt.Rectangle(chartX, chartY, chartwidth, chartheight), new Point(chartX, chartY), info); // self.chartToInfoMap[chart] = info // // self.chartCoordsMap[chart] = [chartX ,chartY,chartwidth, // chartheight] } } } }