List of usage examples for java.awt Graphics2D setColor
public abstract void setColor(Color c);
From source file:de.tor.tribes.ui.panels.MinimapPanel.java
protected BufferedImage getScaledImage(int width, int height) { BufferedImage tempImg = ImageUtils.createCompatibleBufferedImage(width, height, BufferedImage.TYPE_INT_ARGB); Graphics2D g2d = (Graphics2D) tempImg.getGraphics(); g2d.setColor(new Color(35, 125, 0)); g2d.fillRect(0, 0, tempImg.getWidth(null), tempImg.getHeight(null)); g2d.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BICUBIC); g2d.drawImage(mBuffer, 0, 0, width, height, 0, 0, mBuffer.getWidth(), mBuffer.getHeight(), null); g2d.dispose();// ww w . jav a2 s . c o m return tempImg; }
From source file:org.apache.fop.svg.AbstractFOPTextPainter.java
/** * Paint a single text run on the Graphics2D at a given location. * @param run the text run to paint// w ww . j a va 2s.c o m * @param g2d the Graphics2D to paint to * @param loc the current location of the "cursor" * @return the new location of the "cursor" after painting the text run */ protected Point2D paintTextRun(StrokingTextPainter.TextRun run, Graphics2D g2d, Point2D loc) { AttributedCharacterIterator aci = run.getACI(); aci.first(); updateLocationFromACI(aci, loc); AffineTransform at = g2d.getTransform(); loc = at.transform(loc, null); // font Font font = getFont(aci); if (font != null) { nativeTextHandler.setOverrideFont(font); } // color TextPaintInfo tpi = (TextPaintInfo) aci .getAttribute(GVTAttributedCharacterIterator.TextAttribute.PAINT_INFO); if (tpi == null) { return loc; } Paint foreground = tpi.fillPaint; if (foreground instanceof Color) { Color col = (Color) foreground; g2d.setColor(col); } g2d.setPaint(foreground); // text anchor TextNode.Anchor anchor = (TextNode.Anchor) aci .getAttribute(GVTAttributedCharacterIterator.TextAttribute.ANCHOR_TYPE); // text String txt = getText(aci); float advance = getStringWidth(txt, font); float tx = 0; if (anchor != null) { switch (anchor.getType()) { case TextNode.Anchor.ANCHOR_MIDDLE: tx = -advance / 2; break; case TextNode.Anchor.ANCHOR_END: tx = -advance; break; default: //nop } } // draw string double x = loc.getX(); double y = loc.getY(); try { try { nativeTextHandler.drawString(g2d, txt, (float) x + tx, (float) y); } catch (IOException ioe) { if (g2d instanceof AFPGraphics2D) { ((AFPGraphics2D) g2d).handleIOException(ioe); } } } finally { nativeTextHandler.setOverrideFont(null); } loc.setLocation(loc.getX() + advance, loc.getY()); return loc; }
From source file:net.pms.util.GenericIcons.java
/** * Add the format(container) name of the media to the generic icon image. * * @param image BufferdImage to be the label added * @param label the media container name to be added as a label * @param renderer the renderer configuration * * @return the generic icon with the container label added and scaled in accordance with renderer setting *///from w w w .ja v a2 s .com private DLNAThumbnail addFormatLabelToImage(String label, ImageFormat imageFormat, IconType iconType) throws IOException { BufferedImage image; switch (iconType) { case AUDIO: image = genericAudioIcon; break; case IMAGE: image = genericImageIcon; break; case VIDEO: image = genericVideoIcon; break; default: image = genericUnknownIcon; } if (image != null) { // Make a copy ColorModel colorModel = image.getColorModel(); image = new BufferedImage(colorModel, image.copyData(null), colorModel.isAlphaPremultiplied(), null); } ByteArrayOutputStream out = null; if (label != null && image != null) { out = new ByteArrayOutputStream(); Graphics2D g = image.createGraphics(); g.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY); g.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON); try { int size = 40; Font font = new Font(Font.SANS_SERIF, Font.BOLD, size); FontMetrics metrics = g.getFontMetrics(font); while (size > 7 && metrics.stringWidth(label) > 135) { size--; font = new Font(Font.SANS_SERIF, Font.BOLD, size); metrics = g.getFontMetrics(font); } // Text center point 127x, 49y - calculate centering coordinates int x = 127 - metrics.stringWidth(label) / 2; int y = 46 + metrics.getAscent() / 2; g.drawImage(image, 0, 0, null); g.setColor(Color.WHITE); g.setFont(font); g.drawString(label, x, y); ImageIO.setUseCache(false); ImageIOTools.imageIOWrite(image, imageFormat.toString(), out); } finally { g.dispose(); } } return out != null ? DLNAThumbnail.toThumbnail(out.toByteArray(), 0, 0, ScaleType.MAX, imageFormat, false) : null; }
From source file:com.alibaba.simpleimage.render.CornerDrawTextItem.java
@Override public void drawText(Graphics2D graphics, int width, int height) { if (StringUtils.isBlank(text)) { return;//from w ww . j a v a 2s . co m } int x = 0, y = 0; // ? int textLength = (int) (width * textWidthPercent); // ?? int fontsize = textLength / text.length(); // ?.....? if (fontsize < minFontSize) { return; } float fsize = (float) fontsize; Font font = defaultFont.deriveFont(fsize); graphics.setFont(font); FontRenderContext context = graphics.getFontRenderContext(); int sw = (int) font.getStringBounds(text, context).getWidth(); // ?? if (width > height) { y = height / 4; } else { y = width / 4; } int halflen = sw / 2; if (halflen <= (y - fontsize)) { x = y - halflen; } else { x = fontsize; } if (x <= 0 || y <= 0) { return; } if (fontShadowColor != null) { graphics.setColor(fontShadowColor); graphics.drawString(text, x + getShadowTranslation(fontsize), y + getShadowTranslation(fontsize)); } graphics.setColor(fontColor); graphics.drawString(text, x, y); if (width > height) { y = height - (height / 4); } else { y = height - (width / 4); } halflen = sw / 2; if (halflen <= (height - y - fontsize)) { x = width - (height - y) - halflen; } else { x = width - sw - fontsize; } if (x <= 0 || y <= 0) { return; } if (fontShadowColor != null) { graphics.setColor(fontShadowColor); graphics.drawString(text, x + getShadowTranslation(fontsize), y + getShadowTranslation(fontsize)); } graphics.setColor(fontColor); graphics.drawString(text, x, y); }
From source file:com.github.lindenb.jvarkit.tools.misc.BamCmpCoverage.java
@Override public Collection<Throwable> call() throws Exception { if (getOutputFile() == null) { return wrapException("output image file not defined"); }/*from w w w . j a va2 s . c om*/ if (this.imgageSize < 1) { return wrapException("Bad image size:" + this.imgageSize); } if (this.minDepth < 0) { return wrapException("Bad min depth : " + this.minDepth); } if (this.minDepth >= this.maxDepth) { return wrapException("Bad min<max depth : " + this.minDepth + "<" + this.maxDepth); } if (this.getBedFile() != null) { readBedFile(this.getBedFile()); } if (regionStr != null && this.intervals != null) { return wrapException("bed and interval both defined."); } final SamRecordFilter filter = new SamRecordFilter() { @Override public boolean filterOut(SAMRecord first, SAMRecord second) { return filterOut(first); } @Override public boolean filterOut(SAMRecord rec) { if (rec.getReadUnmappedFlag()) return true; if (rec.isSecondaryOrSupplementary()) return true; if (rec.getDuplicateReadFlag()) return true; if (rec.getNotPrimaryAlignmentFlag()) return true; if (rec.getReadFailsVendorQualityCheckFlag()) return true; if (rec.getMappingQuality() == 0) return true; /* ignore non-overlapping BED, already checked with QuertInterval if( intervals!=null && ! intervals.containsOverlapping( new Interval(rec.getReferenceName(), rec.getAlignmentStart(), rec.getAlignmentEnd())) ) { return true; } */ return false; } }; Set<File> files = new HashSet<File>(); try { SamReaderFactory srf = SamReaderFactory.makeDefault().validationStringency(ValidationStringency.SILENT); srf.disable(SamReaderFactory.Option.EAGERLY_DECODE); srf.disable(SamReaderFactory.Option.INCLUDE_SOURCE_IN_RECORDS); srf.disable(SamReaderFactory.Option.VALIDATE_CRC_CHECKSUMS); final List<String> args = this.getInputFiles(); for (String arg : args) { File f = new File(arg); if (f.getName().endsWith(".list")) { LOG.info("Reading BAM list from " + f); BufferedReader in = IOUtils.openFileForBufferedReading(f); String line; while ((line = in.readLine()) != null) { if (line.trim().isEmpty() || line.startsWith("#")) continue; files.add(new File(line)); } in.close(); } else { files.add(f); } } if (files.isEmpty()) { return wrapException("No BAM defined"); } Comparator<SAMRecord> comparator = new Comparator<SAMRecord>() { @Override public int compare(SAMRecord samRecord1, SAMRecord samRecord2) { final int refIndex1 = samRecord1.getReferenceIndex(); final int refIndex2 = samRecord2.getReferenceIndex(); if (refIndex1 == -1) { return (refIndex2 == -1 ? 0 : 1); } else if (refIndex2 == -1) { return -1; } final int cmp = refIndex1 - refIndex2; if (cmp != 0) { return cmp; } return samRecord1.getAlignmentStart() - samRecord2.getAlignmentStart(); } }; List<SamReader> readers = new ArrayList<SamReader>(files.size()); List<CloseableIterator<SAMRecord>> iterators = new ArrayList<CloseableIterator<SAMRecord>>( files.size()); Set<String> samples = new TreeSet<String>(); SAMSequenceDictionary dict = null; /* will be initialized below once, if needed */ QueryInterval queryIntervalArray[] = null; //scan samples names for (File bamFile : files) { SamReader r = srf.open(bamFile); readers.add(r); SAMFileHeader h = r.getFileHeader(); if (h.getSortOrder() != SortOrder.coordinate) { r.close(); return wrapException("file " + bamFile + " not sorted on coordinate"); } if (dict == null) { dict = h.getSequenceDictionary(); } else if (!SequenceUtil.areSequenceDictionariesEqual(dict, h.getSequenceDictionary())) { return wrapException("Found more than one dictint sequence dictionary"); } //fill query interval once List<QueryInterval> queryIntervals = new ArrayList<>(); if (regionStr != null && queryIntervalArray == null) { int colon = regionStr.indexOf(':'); String chrom; int chromStart; int chromEnd; if (colon == -1) { chrom = regionStr; } else { chrom = regionStr.substring(0, colon); } SAMSequenceRecord ssr = dict.getSequence(chrom); if (ssr == null) { return wrapException("Chromosome " + chrom + " not present in dictionary"); } int hyphen = regionStr.indexOf('-', colon + 1); if (hyphen != -1) { chromStart = Integer.parseInt(regionStr.substring(colon + 1, hyphen)); chromEnd = Integer.parseInt(regionStr.substring(hyphen + 1)); } else { chromStart = 0; chromEnd = ssr.getSequenceLength() - 1; } if (chromStart < 0 || chromEnd < chromStart) { return wrapException("bad position in " + regionStr); } queryIntervals.add(new QueryInterval(ssr.getSequenceIndex(), chromStart, chromEnd)); } if (this.intervals != null && queryIntervalArray == null) { for (Interval interval : this.intervals.keySet()) { SAMSequenceRecord ssr = dict.getSequence(interval.getContig()); if (ssr == null) { return wrapException( "Chromosome " + interval.getContig() + " not present in dictionary"); } queryIntervals.add( new QueryInterval(ssr.getSequenceIndex(), interval.getStart(), interval.getEnd())); } } if (!queryIntervals.isEmpty() && queryIntervalArray == null) { Collections.sort(queryIntervals); queryIntervalArray = queryIntervals.toArray(new QueryInterval[queryIntervals.size()]); } for (SAMReadGroupRecord rg : h.getReadGroups()) { String sample = rg.getSample(); if (sample == null) continue; samples.add(sample); } CloseableIterator<SAMRecord> reciterator = null; if (queryIntervalArray == null) { reciterator = r.iterator(); } else { reciterator = r.query(queryIntervalArray, false); } reciterator = new FilteringIterator(reciterator, filter); iterators.add(reciterator); } //free GC queryIntervalArray = null; LOG.info("Samples:" + samples.size()); for (String sample : samples) { this.sample2column.put(sample, this.sample2column.size()); } //create merging sam-reader MergingSamRecordIterator iter = new MergingSamRecordIterator(comparator, iterators); //create image LOG.info("Creating image " + this.imgageSize + "x" + this.imgageSize); this.image = new BufferedImage(this.imgageSize, this.imgageSize, BufferedImage.TYPE_INT_RGB); Graphics2D g = this.image.createGraphics(); this.marginWidth = this.imgageSize * 0.05; double drawingWidth = (this.imgageSize - 1) - marginWidth; this.sampleWidth = drawingWidth / samples.size(); //g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); g.setColor(Color.WHITE); g.fillRect(0, 0, this.imgageSize, this.imgageSize); g.setColor(Color.BLACK); Hershey hershey = new Hershey(); for (String sample_x : samples) { double labelHeight = marginWidth; if (labelHeight > 50) labelHeight = 50; g.setColor(Color.BLACK); hershey.paint(g, sample_x, marginWidth + sample2column.get(sample_x) * sampleWidth, marginWidth - labelHeight, sampleWidth * 0.9, labelHeight * 0.9); AffineTransform old = g.getTransform(); AffineTransform tr = AffineTransform.getTranslateInstance(marginWidth, marginWidth + sample2column.get(sample_x) * sampleWidth); tr.rotate(Math.PI / 2); g.setTransform(tr); hershey.paint(g, sample_x, 0.0, 0.0, sampleWidth * 0.9, labelHeight * 0.9); //g.drawString(this.tabixFile.getFile().getName(),0,0); g.setTransform(old); for (String sample_y : samples) { Rectangle2D rect = new Rectangle2D.Double( marginWidth + sample2column.get(sample_x) * sampleWidth, marginWidth + sample2column.get(sample_y) * sampleWidth, sampleWidth, sampleWidth); g.setColor(Color.BLUE); g.draw(new Line2D.Double(rect.getMinX(), rect.getMinY(), rect.getMaxX(), rect.getMaxY())); g.setColor(Color.BLACK); g.draw(rect); } } //ceate bit-array BitSampleMatrix bitMatrix = new BitSampleMatrix(samples.size()); //preivous chrom //int prev_tid=-1; BufferedList<Depth> depthList = new BufferedList<Depth>(); g.setColor(Color.BLACK); SAMSequenceDictionaryProgress progress = new SAMSequenceDictionaryProgress(dict); LOG.info("Scanning bams..."); while (iter.hasNext()) { SAMRecord rec = iter.next(); if (filter.filterOut(rec)) continue; progress.watch(rec); SAMReadGroupRecord gr = rec.getReadGroup(); if (gr == null) continue; String sample = gr.getSample(); if (sample == null) continue; int sample_id = this.sample2column.get(sample); Cigar cigar = rec.getCigar(); if (cigar == null) continue; int refPos = rec.getAlignmentStart(); /* cleanup front pos */ while (!depthList.isEmpty()) { Depth front = depthList.getFirst(); if (front.tid != rec.getReferenceIndex().intValue() || front.pos < refPos) { paint(bitMatrix, front); depthList.removeFirst(); continue; } else { break; } } for (CigarElement ce : cigar.getCigarElements()) { CigarOperator op = ce.getOperator(); if (!op.consumesReferenceBases()) continue; if (op.consumesReadBases()) { for (int i = 0; i < ce.getLength(); ++i) { Depth depth = null; int pos = refPos + i; //ignore non-overlapping BED if (this.intervals != null && !this.intervals .containsOverlapping(new Interval(rec.getReferenceName(), pos, pos))) { continue; } else if (depthList.isEmpty()) { depth = new Depth(); depth.pos = pos; depth.tid = rec.getReferenceIndex(); depthList.add(depth); } else if (depthList.getLast().pos < pos) { Depth prev = depthList.getLast(); while (prev.pos < pos) { depth = new Depth(); depth.pos = prev.pos + 1; depth.tid = rec.getReferenceIndex(); depthList.add(depth); prev = depth; } depth = prev; } else { int lastPos = depthList.get(depthList.size() - 1).pos; int distance = lastPos - pos; int indexInList = (depthList.size() - 1) - (distance); if (indexInList < 0) { //can appen when BED declared and partially overlap the read continue; } depth = depthList.get((depthList.size() - 1) - (distance)); if (depth.pos != pos) { return wrapException(" " + pos + " vs " + depth.pos + " " + lastPos); } } depth.depths[sample_id]++; } } refPos += ce.getLength(); } } while (!depthList.isEmpty()) { //paint(g,depthList.remove(0)); paint(bitMatrix, depthList.remove(0)); } progress.finish(); iter.close(); //paint bitset for (int x = 0; x < bitMatrix.n_samples; ++x) { for (int y = 0; y < bitMatrix.n_samples; ++y) { LOG.info("Painting...(" + x + "/" + y + ")"); paint(g, bitMatrix.get(x, y)); } } g.dispose(); //close readers for (SamReader r : readers) r.close(); //save file LOG.info("saving " + getOutputFile()); if (getOutputFile().getName().toLowerCase().endsWith(".png")) { ImageIO.write(this.image, "PNG", getOutputFile()); } else { ImageIO.write(this.image, "JPG", getOutputFile()); } return Collections.emptyList(); } catch (Exception err) { return wrapException(err); } finally { } }
From source file:net.sf.maltcms.chromaui.charts.overlay.Peak1DHeatmapOverlay.java
/** * * @param g2//from ww w.j ava 2 s . com * @param chartPanel */ @Override public void paintOverlay(Graphics2D g2, ChartPanel chartPanel) { if (isVisible()) { Shape savedClip = g2.getClip(); Rectangle2D dataArea = chartPanel.getScreenDataArea(); g2.clip(dataArea); JFreeChart chart = chartPanel.getChart(); XYPlot plot = (XYPlot) chart.getPlot(); ValueAxis xAxis = plot.getDomainAxis(); RectangleEdge xAxisEdge = plot.getDomainAxisEdge(); ValueAxis yAxis = plot.getRangeAxis(); RectangleEdge yAxisEdge = plot.getRangeAxisEdge(); Color c = g2.getColor(); Color fillColor = peakAnnotations.getColor(); if (fillColor == null || fillColor.equals(Color.WHITE) || fillColor.equals(new Color(255, 255, 255, 0))) { Logger.getLogger(getClass().getName()) .info("Peak annotation color was null or white, using color from treatment group!"); fillColor = peakAnnotations.getChromatogram().getTreatmentGroup().getColor(); } g2.setColor(ChartCustomizer.withAlpha(fillColor, 0.5f)); for (IPeakAnnotationDescriptor descr : peakAnnotations.getMembers()) { double x = descr.getApexTime(); double xx = xAxis.valueToJava2D(x, dataArea, xAxisEdge); double width = xAxis.valueToJava2D(1, dataArea, xAxisEdge); double mzRange = (descr.getMassValues()[descr.getMassValues().length - 1] - descr.getMassValues()[0]); double y = mzRange / 2.0d; double yy = yAxis.valueToJava2D(y, dataArea, yAxisEdge); double height = yAxis.valueToJava2D(mzRange, dataArea, yAxisEdge); AffineTransform at = AffineTransform.getTranslateInstance(xx, yy); at.concatenate(AffineTransform.getTranslateInstance(-x, -y)); Rectangle2D.Double r = new Rectangle2D.Double(xx - (width / 2.0d), yy, width, height); g2.fill(at.createTransformedShape(r)); } g2.setColor(c); g2.setClip(savedClip); } }
From source file:com.igormaznitsa.mindmap.swing.panel.MindMapPanel.java
private static void drawJumps(final Graphics2D gfx, final MindMap map, final MindMapPanelConfig cfg) { final List<Topic> allTopicsWithJumps = map.findAllTopicsForExtraType(Extra.ExtraType.TOPIC); final float scaledSize = cfg.safeScaleFloatValue(cfg.getJumpLinkWidth(), 0.1f); final Stroke lineStroke = new BasicStroke(scaledSize, BasicStroke.CAP_ROUND, BasicStroke.JOIN_BEVEL, 0, new float[] { scaledSize, scaledSize * 3.0f }, 0); final Stroke arrowStroke = new BasicStroke(cfg.safeScaleFloatValue(cfg.getJumpLinkWidth() * 1.0f, 0.3f)); gfx.setColor(cfg.getJumpLinkColor()); final float arrowSize = cfg.safeScaleFloatValue(10.0f * cfg.getJumpLinkWidth(), 0.2f); for (Topic src : allTopicsWithJumps) { final ExtraTopic extra = (ExtraTopic) src.getExtras().get(Extra.ExtraType.TOPIC); src = MindMapUtils.isHidden(src) ? MindMapUtils.findFirstVisibleAncestor(src) : src; final AbstractElement srcElement = (AbstractElement) src.getPayload(); if (extra != null) { Topic dst = map.findTopicForLink(extra); if (dst != null) { if (MindMapUtils.isHidden(dst)) { dst = MindMapUtils.findFirstVisibleAncestor(dst); if (dst == src) { dst = null;/*from w ww . j a va2s . com*/ } } if (dst != null) { final AbstractElement dstElement = (AbstractElement) dst.getPayload(); if (!MindMapUtils.isHidden(dst)) { final Rectangle2D srcRect = srcElement.getBounds(); final Rectangle2D dstRect = dstElement.getBounds(); drawArrowToDestination(gfx, srcRect, dstRect, lineStroke, arrowStroke, arrowSize); } } } } } }
From source file:org.tsho.dmc2.core.chart.CyclesRenderer.java
private void checkStability(double cycleModulus[], Graphics2D g2) { /*check eigval modulus. Depending on it, set color.*/ boolean stable = false; boolean unstable = false; boolean one = false; int dim = cycleModulus.length; for (int i = 0; i < dim; i++) { if (stable) if (cycleModulus[i] >= 1) { stable = false;// w ww . ja v a 2 s . co m break; } else continue; if (unstable) if (cycleModulus[i] <= 1) { unstable = false; break; } else continue; if (Math.abs(cycleModulus[i] - 1) <= epsilon) { one = true; break; } else if (cycleModulus[i] < 1) stable = true; else if (cycleModulus[i] > 1) unstable = true; else break; } if (one) g2.setColor(Color.BLACK); else if (stable) g2.setColor(Color.GREEN); else if (unstable) g2.setColor(Color.RED); else g2.setColor(Color.BLUE); }
From source file:no.met.jtimeseries.chart.XYCloudSymbolRenderer.java
/** * Draws the visual representation of a single symbol. *///from ww w . j a v a2 s .c o m @Override public void drawItem(Graphics2D g2d, XYItemRendererState state, Rectangle2D plotArea, PlotRenderingInfo info, XYPlot plot, ValueAxis domainAxis, ValueAxis rangeAxis, XYDataset dataset, int series, int item, CrosshairState crosshairState, int pass) { // Needs a new graphics object to use translate() and rotate() Graphics2D g2 = (Graphics2D) g2d.create(); g2.setRenderingHints(renderHints); double middleY = plotArea.getCenterY(); CloudDataset cloudData = (CloudDataset) dataset; Number x = cloudData.getX(series, item); double middleX = domainAxis.valueToJava2D(x.doubleValue(), plotArea, plot.getDomainAxisEdge()); g2.translate((int) middleX, (int) middleY); // make x=0, y=0 the middle of the symbol g2.setStroke(new BasicStroke()); double height = plotArea.getHeight() - 2; // we set the width to be 20 which is the same as the weather symbols double width = calculateWidth(plotArea.getWidth()); double startX = -(width / 2); double startY[] = { -(height / 2), -(height / 4), 0, (height / 4) }; double values[] = { (cloudData.getHighClouds(series, item).doubleValue() / 100.0), (cloudData.getMediumClouds(series, item).doubleValue() / 100.0), (cloudData.getLowClouds(series, item).doubleValue() / 100.0), (cloudData.getFog(series, item).doubleValue() / 100.0) }; for (int i = 0; i < values.length; i++) { // for each cloud type g2.setColor(new Color(96, 96, 96)); g2.fill(new Rectangle2D.Double(startX, startY[i], (width * values[i]), (height / 4 - 1))); // plot could g2.setColor(new Color(97, 204, 247)); g2.fill(new Rectangle2D.Double(startX + (width * values[i]), startY[i], (width * (1 - values[i])), (height / 4 - 1))); // plot sky } }
From source file:org.yccheok.jstock.gui.charting.ChartLayerUI.java
@Override protected void paintLayer(Graphics2D g2, JXLayer<? extends V> layer) { super.paintLayer(g2, layer); if (this.mainTraceInfo.getPoint() == null) { return;//w w w . j av a 2 s.c om } final Object oldValueAntiAlias = g2.getRenderingHint(RenderingHints.KEY_ANTIALIASING); final Color oldColor = g2.getColor(); g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); g2.setColor(COLOR_BLUE); final int BALL_RADIUS = 8; g2.fillOval((int) (this.mainTraceInfo.getPoint().getX() - (BALL_RADIUS >> 1) + 0.5), (int) (this.mainTraceInfo.getPoint().getY() - (BALL_RADIUS >> 1) + 0.5), BALL_RADIUS, BALL_RADIUS); for (TraceInfo indicatorTraceInfo : this.indicatorTraceInfos) { final Point2D point = indicatorTraceInfo.getPoint(); if (null == point) { continue; } g2.fillOval((int) (point.getX() - (BALL_RADIUS >> 1) + 0.5), (int) (point.getY() - (BALL_RADIUS >> 1) + 0.5), BALL_RADIUS, BALL_RADIUS); } g2.setColor(oldColor); g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, oldValueAntiAlias); this.drawInformationBox(g2, layer); }