List of usage examples for java.awt Graphics2D setColor
public abstract void setColor(Color c);
From source file:org.ietr.preesm.mapper.ui.MyGanttRenderer.java
/** * Draws the tasks/subtasks for one item. * //from w ww.j a v a2s . c om * @param g2 * the graphics device. * @param state * the renderer state. * @param dataArea * the data plot area. * @param plot * the plot. * @param domainAxis * the domain axis. * @param rangeAxis * the range axis. * @param dataset * the data. * @param row * the row index (zero-based). * @param column * the column index (zero-based). */ @Override protected void drawTasks(Graphics2D g2, CategoryItemRendererState state, Rectangle2D dataArea, CategoryPlot plot, CategoryAxis domainAxis, ValueAxis rangeAxis, GanttCategoryDataset dataset, int row, int column) { int count = dataset.getSubIntervalCount(row, column); if (count == 0) { drawTask(g2, state, dataArea, plot, domainAxis, rangeAxis, dataset, row, column); } for (int subinterval = 0; subinterval < count; subinterval++) { RectangleEdge rangeAxisLocation = plot.getRangeAxisEdge(); // value 0 Number value0 = dataset.getStartValue(row, column, subinterval); if (value0 == null) { return; } double translatedValue0 = rangeAxis.valueToJava2D(value0.doubleValue(), dataArea, rangeAxisLocation); // value 1 Number value1 = dataset.getEndValue(row, column, subinterval); if (value1 == null) { return; } double translatedValue1 = rangeAxis.valueToJava2D(value1.doubleValue(), dataArea, rangeAxisLocation); if (translatedValue1 < translatedValue0) { double temp = translatedValue1; translatedValue1 = translatedValue0; translatedValue0 = temp; } double rectStart = calculateBarW0(plot, plot.getOrientation(), dataArea, domainAxis, state, row, column); double rectLength = Math.abs(translatedValue1 - translatedValue0); double rectBreadth = state.getBarWidth(); // DRAW THE BARS... RoundRectangle2D bar = null; bar = new RoundRectangle2D.Double(translatedValue0, rectStart, rectLength, rectBreadth, 10.0, 10.0); /* Paint seriesPaint = */getItemPaint(row, column); if (((TaskSeriesCollection) dataset).getSeriesCount() > 0) if (((TaskSeriesCollection) dataset).getSeries(0).getItemCount() > column) if (((TaskSeriesCollection) dataset).getSeries(0).get(column).getSubtaskCount() > subinterval) { g2.setPaint(getRandomBrightColor(((TaskSeriesCollection) dataset).getSeries(0).get(column) .getSubtask(subinterval).getDescription())); } g2.fill(bar); if (isDrawBarOutline() && state.getBarWidth() > BAR_OUTLINE_WIDTH_THRESHOLD) { g2.setStroke(getItemStroke(row, column)); g2.setPaint(getItemOutlinePaint(row, column)); g2.draw(bar); } // Displaying the tooltip inside the bar if enough space is // available if (getToolTipGenerator(row, column) != null) { // Getting the string to display String tip = getToolTipGenerator(row, column).generateToolTip(dataset, subinterval, column); // Truncting the string if it is too long String subtip = ""; if (rectLength > 0) { double percent = (g2.getFontMetrics().getStringBounds(tip, g2).getWidth() + 10) / rectLength; if (percent > 1.0) { subtip = tip.substring(0, (int) (tip.length() / percent)); } else if (percent > 0) { subtip = tip; } // Setting font and color Font font = new Font("Garamond", Font.BOLD, 12); g2.setFont(font); g2.setColor(Color.WHITE); // Testing width and displaying if (!subtip.isEmpty()) { g2.drawString(subtip, (int) translatedValue0 + 5, (int) rectStart + g2.getFontMetrics().getHeight()); } } } // collect entity and tool tip information... if (state.getInfo() != null) { EntityCollection entities = state.getEntityCollection(); if (entities != null) { String tip = null; if (getToolTipGenerator(row, column) != null) { tip = getToolTipGenerator(row, column).generateToolTip(dataset, subinterval, column); } String url = null; if (getItemURLGenerator(row, column) != null) { url = getItemURLGenerator(row, column).generateURL(dataset, row, column); } CategoryItemEntity entity = new CategoryItemEntity(bar, tip, url, dataset, dataset.getRowKey(row), dataset.getColumnKey(column)); entities.add(entity); } } } }
From source file:SWT2D.java
private void run() { // Create top level shell final Display display = new Display(); final Shell shell = new Shell(display); shell.setText("Java 2D Example"); // GridLayout for canvas and button shell.setLayout(new GridLayout()); // Create container for AWT canvas final Composite canvasComp = new Composite(shell, SWT.EMBEDDED); // Set preferred size GridData data = new GridData(); data.widthHint = 600;//from www . jav a2 s.co m data.heightHint = 500; canvasComp.setLayoutData(data); // Create AWT Frame for Canvas java.awt.Frame canvasFrame = SWT_AWT.new_Frame(canvasComp); // Create Canvas and add it to the Frame final java.awt.Canvas canvas = new java.awt.Canvas(); canvasFrame.add(canvas); // Get graphical context and cast to Java2D final java.awt.Graphics2D g2d = (java.awt.Graphics2D) canvas.getGraphics(); // Enable antialiasing g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); // Remember initial transform final java.awt.geom.AffineTransform origTransform = g2d.getTransform(); // Create Clear button and position it Button clearButton = new Button(shell, SWT.PUSH); clearButton.setText("Clear"); data = new GridData(); data.horizontalAlignment = GridData.CENTER; clearButton.setLayoutData(data); // Event processing for Clear button clearButton.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { // Delete word list and redraw canvas wordList.clear(); canvasComp.redraw(); } }); // Process canvas mouse clicks canvas.addMouseListener(new java.awt.event.MouseListener() { public void mouseClicked(java.awt.event.MouseEvent e) { } public void mouseEntered(java.awt.event.MouseEvent e) { } public void mouseExited(java.awt.event.MouseEvent e) { } public void mousePressed(java.awt.event.MouseEvent e) { // Manage pop-up editor display.syncExec(new Runnable() { public void run() { if (eShell == null) { // Create new Shell: non-modal! eShell = new Shell(shell, SWT.NO_TRIM | SWT.MODELESS); eShell.setLayout(new FillLayout()); // Text input field eText = new Text(eShell, SWT.BORDER); eText.setText("Text rotation in the SWT?"); eShell.pack(); // Set position (Display coordinates) java.awt.Rectangle bounds = canvas.getBounds(); org.eclipse.swt.graphics.Point pos = canvasComp.toDisplay(bounds.width / 2, bounds.height / 2); Point size = eShell.getSize(); eShell.setBounds(pos.x, pos.y, size.x, size.y); // Open Shell eShell.open(); } else if (!eShell.isVisible()) { // Editor versteckt, sichtbar machen eShell.setVisible(true); } else { // Editor is visible - get text String t = eText.getText(); // set editor invisible eShell.setVisible(false); // Add text to list and redraw canvas wordList.add(t); canvasComp.redraw(); } } }); } public void mouseReleased(java.awt.event.MouseEvent e) { } }); // Redraw the canvas canvasComp.addPaintListener(new PaintListener() { public void paintControl(PaintEvent e) { // Pass the redraw task to AWT event queue java.awt.EventQueue.invokeLater(new Runnable() { public void run() { // Compute canvas center java.awt.Rectangle bounds = canvas.getBounds(); int originX = bounds.width / 2; int originY = bounds.height / 2; // Reset canvas g2d.setTransform(origTransform); g2d.setColor(java.awt.Color.WHITE); g2d.fillRect(0, 0, bounds.width, bounds.height); // Set font g2d.setFont(new java.awt.Font("Myriad", java.awt.Font.PLAIN, 32)); double angle = 0d; // Prepare star shape double increment = Math.toRadians(30); Iterator iter = wordList.iterator(); while (iter.hasNext()) { // Determine text colors in RGB color cycle float red = (float) (0.5 + 0.5 * Math.sin(angle)); float green = (float) (0.5 + 0.5 * Math.sin(angle + Math.toRadians(120))); float blue = (float) (0.5 + 0.5 * Math.sin(angle + Math.toRadians(240))); g2d.setColor(new java.awt.Color(red, green, blue)); // Redraw text String text = (String) iter.next(); g2d.drawString(text, originX + 50, originY); // Rotate for next text output g2d.rotate(increment, originX, originY); angle += increment; } } }); } }); // Finish shell and open it shell.pack(); shell.open(); // SWT event processing while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); }
From source file:com.projity.pm.graphic.gantt.GanttRenderer.java
public void paintNonWorkingDays(Graphics2D g2, Rectangle bounds) { BarFormat calFormat = getCalendarFormat(); if (calFormat == null) return;// www . j av a 2 s .c om //non working days Color oldColor = g2.getColor(); Paint oldPaint = g2.getPaint(); CoordinatesConverter coord = ((GanttParams) graphInfo).getCoord(); Project project = coord.getProject(); WorkingCalendar wc = (WorkingCalendar) project.getWorkCalendar(); if (coord.getTimescaleManager().isShowWholeDays()) { boolean useScale2 = coord.getTimescaleManager().getCurrentScaleIndex() == 0; //valid only for current time scales TimeIterator i = coord.getTimeIterator(bounds.getX(), bounds.getMaxX(), useScale2); long startNonworking = -1L, endNonWorking = -1L; Calendar cal = DateTime.calendarInstance(); PredefinedPaint paint = (PredefinedPaint) calFormat.getMiddle().getPaint();//new PredefinedPaint(PredefinedPaint.DOT_LINE,Colors.VERY_LIGHT_GRAY,Color.WHITE); paint.applyPaint(g2, useTextures()); while (i.hasNext()) { TimeInterval interval = i.next(); long s = interval.getStart(); if (CalendarService.getInstance().getDay(wc, s).isWorking()) { if (startNonworking != -1L) { drawNonWorking(g2, startNonworking, endNonWorking, cal, coord, bounds, useScale2); startNonworking = endNonWorking = -1L; } } else { if (startNonworking == -1L) startNonworking = s; endNonWorking = s; } } if (startNonworking != -1L) { drawNonWorking(g2, startNonworking, endNonWorking, cal, coord, bounds, useScale2); startNonworking = endNonWorking = -1L; } } if (container != null) { //scale2 separation lines TimeIterator i = coord.getTimeIterator(bounds.getX(), bounds.getMaxX(), true); g2.setPaint(new PredefinedPaint(PredefinedPaint.DOT_LINE2, Color.GRAY, g2.getBackground())); while (i.hasNext()) { TimeInterval interval = i.next(); int startX = (int) Math.round(coord.toX(interval.getStart())); g2.drawLine(startX, bounds.y, startX, bounds.y + bounds.height); } //project start int projectStartX = (int) Math.round(coord.toX(project.getStart())); if (projectStartX >= bounds.getX() && projectStartX <= bounds.getMaxX()) { g2.setPaint(new PredefinedPaint(PredefinedPaint.DASH_LINE, Color.GRAY, g2.getBackground())); g2.drawLine(projectStartX, bounds.y, projectStartX, bounds.y + bounds.height); } //project start long statusDate = project.getStatusDate(); if (statusDate != 0) { int statusDateX = (int) Math.round(coord.toX(statusDate)); if (statusDateX >= bounds.getX() && statusDateX <= bounds.getMaxX()) { g2.setPaint(new PredefinedPaint(PredefinedPaint.DOT_LINE2, Color.GREEN, g2.getBackground())); g2.drawLine(statusDateX, bounds.y, statusDateX, bounds.y + bounds.height); } } if (oldColor != null) g2.setColor(oldColor); if (oldPaint != null) g2.setPaint(oldPaint); } }
From source file:net.geoprism.dashboard.DashboardMap.java
private BufferedImage getLegendTitleImage(DashboardLayer layer) { FontMetrics fm;// w ww . j av a 2 s. c o m int textWidth; int textHeight; int textBoxHorizontalPadding = 4; int textBoxVerticalPadding = 4; int borderWidth = 2; int paddedTitleHeight; int paddedTitleWidth; int titleLeftPadding = textBoxHorizontalPadding; BufferedImage newLegendTitleBase; Graphics2D newLegendTitleBaseGraphic = null; try { // Build the Font object Font titleFont = new Font(layer.getName(), Font.BOLD, 14); // Build variables for base legend graphic construction try { newLegendTitleBase = new BufferedImage(1, 1, BufferedImage.TYPE_INT_ARGB); newLegendTitleBaseGraphic = newLegendTitleBase.createGraphics(); newLegendTitleBaseGraphic.setFont(titleFont); fm = newLegendTitleBaseGraphic.getFontMetrics(); textHeight = fm.getHeight(); textWidth = fm.stringWidth(layer.getName()); paddedTitleWidth = textWidth + (textBoxHorizontalPadding * 2) + (borderWidth * 2); paddedTitleHeight = textHeight + (textBoxVerticalPadding * 2) + (borderWidth * 2); } finally { // dispose of temporary graphics context if (newLegendTitleBaseGraphic != null) { newLegendTitleBaseGraphic.dispose(); } } titleLeftPadding = ((paddedTitleWidth / 2) - ((textWidth + (textBoxHorizontalPadding * 2) + (borderWidth * 2)) / 2)) + textBoxHorizontalPadding; newLegendTitleBase = new BufferedImage(paddedTitleWidth, paddedTitleHeight, BufferedImage.TYPE_INT_ARGB); newLegendTitleBaseGraphic = newLegendTitleBase.createGraphics(); newLegendTitleBaseGraphic.drawImage(newLegendTitleBase, 0, 0, null); newLegendTitleBaseGraphic.setRenderingHint(RenderingHints.KEY_ALPHA_INTERPOLATION, RenderingHints.VALUE_ALPHA_INTERPOLATION_QUALITY); newLegendTitleBaseGraphic.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); newLegendTitleBaseGraphic.setRenderingHint(RenderingHints.KEY_COLOR_RENDERING, RenderingHints.VALUE_COLOR_RENDER_QUALITY); newLegendTitleBaseGraphic.setRenderingHint(RenderingHints.KEY_DITHERING, RenderingHints.VALUE_DITHER_ENABLE); newLegendTitleBaseGraphic.setRenderingHint(RenderingHints.KEY_FRACTIONALMETRICS, RenderingHints.VALUE_FRACTIONALMETRICS_ON); newLegendTitleBaseGraphic.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BILINEAR); newLegendTitleBaseGraphic.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY); newLegendTitleBaseGraphic.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL, RenderingHints.VALUE_STROKE_PURE); newLegendTitleBaseGraphic.setFont(titleFont); // draw title text fm = newLegendTitleBaseGraphic.getFontMetrics(); newLegendTitleBaseGraphic.setColor(Color.WHITE); newLegendTitleBaseGraphic.drawString(layer.getName(), titleLeftPadding, fm.getAscent() + textBoxVerticalPadding); newLegendTitleBaseGraphic.drawImage(newLegendTitleBase, 0, 0, null); } finally { if (newLegendTitleBaseGraphic != null) { newLegendTitleBaseGraphic.dispose(); } } return newLegendTitleBase; }
From source file:org.yccheok.jstock.gui.charting.InvestmentFlowLayerUI.java
private void drawTitle(Graphics2D g2) { final Object oldValueAntiAlias = g2.getRenderingHint(RenderingHints.KEY_ANTIALIASING); final Color oldColor = g2.getColor(); final Font oldFont = g2.getFont(); g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); final Font titleFont = oldFont.deriveFont(oldFont.getStyle() | Font.BOLD, (float) oldFont.getSize() * 1.5f); final int margin = 5; final FontMetrics titleFontMetrics = g2.getFontMetrics(titleFont); final FontMetrics oldFontMetrics = g2.getFontMetrics(oldFont); final java.text.NumberFormat numberFormat = java.text.NumberFormat.getInstance(); numberFormat.setMaximumFractionDigits(2); numberFormat.setMinimumFractionDigits(2); final double totalInvestValue = this.investmentFlowChartJDialog.getTotalInvestValue(); final double totalROIValue = this.investmentFlowChartJDialog.getTotalROIValue(); final DecimalPlace decimalPlace = JStock.instance().getJStockOptions().getDecimalPlace(); final String invest = org.yccheok.jstock.portfolio.Utils.toCurrencyWithSymbol(decimalPlace, totalInvestValue);// w w w .j a v a 2s . c o m final String roi = org.yccheok.jstock.portfolio.Utils.toCurrencyWithSymbol(decimalPlace, totalROIValue); final double gain = totalROIValue - totalInvestValue; final double percentage = totalInvestValue > 0.0 ? gain / totalInvestValue * 100.0 : 0.0; final String gain_str = org.yccheok.jstock.portfolio.Utils.toCurrencyWithSymbol(decimalPlace, gain); final String percentage_str = numberFormat.format(percentage); final String SELECTED = this.investmentFlowChartJDialog.getCurrentSelectedString(); final String INVEST = GUIBundle.getString("InvestmentFlowLayerUI_Invest"); final String RETURN = GUIBundle.getString("InvestmentFlowLayerUI_Return"); final String GAIN = (SELECTED.length() > 0 ? SELECTED + " " : "") + GUIBundle.getString("InvestmentFlowLayerUI_Gain"); final String LOSS = (SELECTED.length() > 0 ? SELECTED + " " : "") + GUIBundle.getString("InvestmentFlowLayerUI_Loss"); final int string_width = oldFontMetrics.stringWidth(INVEST + ": ") + titleFontMetrics.stringWidth(invest + " ") + oldFontMetrics.stringWidth(RETURN + ": ") + titleFontMetrics.stringWidth(roi + " ") + oldFontMetrics.stringWidth((gain >= 0 ? GAIN : LOSS) + ": ") + titleFontMetrics.stringWidth(gain_str + " (" + percentage_str + "%)"); int x = (int) (this.investmentFlowChartJDialog.getChartPanel().getWidth() - string_width) >> 1; final int y = margin + titleFontMetrics.getAscent(); g2.setFont(oldFont); g2.drawString(INVEST + ": ", x, y); x += oldFontMetrics.stringWidth(INVEST + ": "); g2.setFont(titleFont); g2.drawString(invest + " ", x, y); x += titleFontMetrics.stringWidth(invest + " "); g2.setFont(oldFont); g2.drawString(RETURN + ": ", x, y); x += oldFontMetrics.stringWidth(RETURN + ": "); g2.setFont(titleFont); g2.drawString(roi + " ", x, y); x += titleFontMetrics.stringWidth(roi + " "); g2.setFont(oldFont); if (gain >= 0) { if (gain > 0) { if (org.yccheok.jstock.engine.Utils.isFallBelowAndRiseAboveColorReverse()) { g2.setColor(JStock.instance().getJStockOptions().getLowerNumericalValueForegroundColor()); } else { g2.setColor(JStock.instance().getJStockOptions().getHigherNumericalValueForegroundColor()); } } g2.drawString(GAIN + ": ", x, y); x += oldFontMetrics.stringWidth(GAIN + ": "); } else { if (org.yccheok.jstock.engine.Utils.isFallBelowAndRiseAboveColorReverse()) { g2.setColor(JStock.instance().getJStockOptions().getHigherNumericalValueForegroundColor()); } else { g2.setColor(JStock.instance().getJStockOptions().getLowerNumericalValueForegroundColor()); } g2.drawString(LOSS + ": ", x, y); x += oldFontMetrics.stringWidth(LOSS + ": "); } g2.setFont(titleFont); g2.drawString(gain_str + " (" + percentage_str + "%)", x, y); g2.setColor(oldColor); g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, oldValueAntiAlias); g2.setFont(oldFont); }
From source file:org.forester.archaeopteryx.TreePanel.java
final private void paintFoundNode(final int x, final int y, final Graphics2D g) { g.setColor(getTreeColorSet().getFoundColor()); g.fillRect(x - TreePanel.HALF_BOX_SIZE, y - TreePanel.HALF_BOX_SIZE, TreePanel.BOX_SIZE, TreePanel.BOX_SIZE);//from w w w . ja va2 s .c om }
From source file:org.forester.archaeopteryx.TreePanel.java
final private void paintBranchLite(final Graphics2D g, final float x1, final float x2, final float y1, final float y2, final PhylogenyNode node) { g.setColor(getTreeColorSet().getOvColor()); if (getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.TRIANGULAR) { drawLine(x1, y1, x2, y2, g);//from ww w. j a va2 s.co m } else if (getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.CONVEX) { _quad_curve.setCurve(x1, y1, x1, y2, x2, y2); (g).draw(_quad_curve); } else if (getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.CURVED) { final float dx = x2 - x1; final float dy = y2 - y1; _cubic_curve.setCurve(x1, y1, x1 + (dx * 0.4f), y1 + (dy * 0.2f), x1 + (dx * 0.6f), y1 + (dy * 0.8f), x2, y2); (g).draw(_cubic_curve); } else { final float x2a = x2; final float x1a = x1; // draw the vertical line if (node.isFirstChildNode() || node.isLastChildNode()) { drawLine(x1, y1, x1, y2, g); } // draw the horizontal line drawLine(x1a, y2, x2a, y2, g); } }
From source file:au.org.ala.biocache.web.WMSController.java
void drawUncertaintyCircles(SpatialSearchRequestParams requestParams, WmsEnv vars, int height, int width, double[] pbbox, double[] mbbox, double width_mult, double height_mult, Graphics2D g, String[] originalFqs, String[] boundingBoxFqs, boolean is4326, double[] tilebbox) throws Exception { //draw uncertainty circles double hmult = (height / (mbbox[3] - mbbox[1])); //only draw uncertainty if max radius will be > 1 pixels if (vars.uncertainty && MAX_UNCERTAINTY * hmult > 1) { //uncertainty colour/fq/radius, [0]=map, [1]=not specified, [2]=too large Color[] uncertaintyColours = { new Color(255, 170, 0, vars.alpha), new Color(255, 255, 100, vars.alpha), new Color(50, 255, 50, vars.alpha) }; //TODO: don't assume MAX_UNCERTAINTY > default_uncertainty String[] uncertaintyFqs = { "coordinate_uncertainty:[* TO " + MAX_UNCERTAINTY + "] AND -assertions:uncertaintyNotSpecified", "assertions:uncertaintyNotSpecified", "coordinate_uncertainty:[" + MAX_UNCERTAINTY + " TO *]" }; double[] uncertaintyR = { -1, MAX_UNCERTAINTY, MAX_UNCERTAINTY }; String[] fqs = new String[originalFqs.length + 3]; System.arraycopy(originalFqs, 0, fqs, 3, originalFqs.length); fqs[1] = boundingBoxFqs[0];//from ww w . j a v a 2 s.com fqs[2] = boundingBoxFqs[1]; requestParams.setPageSize(DEFAULT_PAGE_SIZE); for (int j = 0; j < uncertaintyFqs.length; j++) { //do not display for [1]=not specified if (j == 1) { continue; } fqs[0] = uncertaintyFqs[j]; requestParams.setFq(fqs); requestParams.setFl("longitude,latitude,coordinate_uncertainty"); //only retrieve longitude and latitude requestParams.setFacet(false); //TODO: paging SolrDocumentList sdl = searchDAO.findByFulltext(requestParams); //for 4326 double top = tilebbox[3]; double bottom = tilebbox[1]; double left = tilebbox[0]; double right = tilebbox[2]; double lng, lat; int x, y; int uncertaintyRadius = (int) Math.ceil(uncertaintyR[j] * hmult); if (sdl != null && sdl.size() > 0) { g.setColor(uncertaintyColours[j]); for (int i = 0; i < sdl.size(); i++) { if (uncertaintyR[j] < 0) { uncertaintyRadius = (int) Math .ceil((Double) sdl.get(i).getFieldValue("coordinate_uncertainty") * hmult); } lng = (Double) sdl.get(i).getFieldValue("longitude"); lat = (Double) sdl.get(i).getFieldValue("latitude"); if (is4326) { x = convertLngToPixel4326(lng, left, right, width); y = convertLatToPixel4326(lat, top, bottom, height); } else { x = (int) ((convertLngToPixel(lng) - pbbox[0]) * width_mult); y = (int) ((convertLatToPixel(lat) - pbbox[3]) * height_mult); } if (uncertaintyRadius > 0) { g.drawOval(x - uncertaintyRadius, y - uncertaintyRadius, uncertaintyRadius * 2, uncertaintyRadius * 2); } else { g.drawRect(x, y, 1, 1); } } } } } }
From source file:org.forester.archaeopteryx.TreePanel.java
final private void paintCollapsedNode(final Graphics2D g, final PhylogenyNode node, final boolean to_graphics_file, final boolean to_pdf, final boolean is_in_found_nodes) { if ((to_pdf || to_graphics_file) && getOptions().isPrintBlackAndWhite()) { g.setColor(Color.BLACK); } else if (is_in_found_nodes) { g.setColor(getTreeColorSet().getFoundColor()); } else if (getControlPanel().isColorAccordingToTaxonomy()) { g.setColor(getTaxonomyBasedColor(node)); } else {//from www .j a va 2 s . c om g.setColor(getTreeColorSet().getCollapseFillColor()); } double d = node.getAllExternalDescendants().size(); if (d > 1000) { d = (3 * _y_distance) / 3; } else { d = (Math.log10(d) * _y_distance) / 2.5; } if (d < BOX_SIZE) { d = BOX_SIZE; } _polygon.reset(); _polygon.addPoint(ForesterUtil.roundToInt(node.getXcoord() - TreePanel.BOX_SIZE), ForesterUtil.roundToInt(node.getYcoord())); _polygon.addPoint(ForesterUtil.roundToInt(node.getXcoord() + TreePanel.BOX_SIZE), ForesterUtil.roundToInt(node.getYcoord() - d)); _polygon.addPoint(ForesterUtil.roundToInt(node.getXcoord() + TreePanel.BOX_SIZE), ForesterUtil.roundToInt(node.getYcoord() + d)); g.fillPolygon(_polygon); paintNodeData(g, node, to_graphics_file, to_pdf, is_in_found_nodes); }
From source file:org.forester.archaeopteryx.TreePanel.java
final private void paintBranchLength(final Graphics2D g, final PhylogenyNode node, final boolean to_pdf, final boolean to_graphics_file) { g.setFont(getTreeFontSet().getSmallFont()); if ((to_pdf || to_graphics_file) && getOptions().isPrintBlackAndWhite()) { g.setColor(Color.BLACK); } else {/* ww w.ja va 2 s . c om*/ g.setColor(getTreeColorSet().getBranchLengthColor()); } if (!node.isRoot()) { if (getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.EURO_STYLE) { TreePanel.drawString(FORMATTER_BRANCH_LENGTH.format(node.getDistanceToParent()), node.getParent().getXcoord() + EURO_D, node.getYcoord() - getTreeFontSet()._small_max_descent, g); } else if (getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.ROUNDED) { TreePanel.drawString(FORMATTER_BRANCH_LENGTH.format(node.getDistanceToParent()), node.getParent().getXcoord() + ROUNDED_D, node.getYcoord() - getTreeFontSet()._small_max_descent, g); } else { TreePanel.drawString(FORMATTER_BRANCH_LENGTH.format(node.getDistanceToParent()), node.getParent().getXcoord() + 3, node.getYcoord() - getTreeFontSet()._small_max_descent, g); } } else { TreePanel.drawString(FORMATTER_BRANCH_LENGTH.format(node.getDistanceToParent()), 3, node.getYcoord() - getTreeFontSet()._small_max_descent, g); } }