List of usage examples for java.awt Color green
Color green
To view the source code for java.awt Color green.
Click Source Link
From source file:simz1.StackedBarChart.java
public void BreadGraph() { DefaultCategoryDataset bidata = new DefaultCategoryDataset(); bidata.setValue(bi1, "sales", d1); bidata.setValue(bi2, "sales", d2); bidata.setValue(bi3, "sales", d3); bidata.setValue(bi4, "sales", d4); bidata.setValue(bi5, "sales", d5); bidata.setValue(bi6, "sales", d6); bidata.setValue(bi7, "sales", d7); JFreeChart chart3 = ChartFactory.createLineChart("Sales of Bread Items last week", "Date", "sales", bidata, PlotOrientation.VERTICAL, false, true, false); CategoryPlot c3 = chart3.getCategoryPlot(); c3.setBackgroundPaint(Color.white); c3.getRenderer().setSeriesPaint(0, Color.GREEN); //c3.setRangeGridlinePaint(Color.green); ChartPanel c3Panel = new ChartPanel(chart3); mhp.chartPanel.removeAll();// ww w. j a va 2s . c o m mhp.chartPanel.add(c3Panel); }
From source file:monitor.processing.OLD.Drawing3D.java
public void drawTree(BaseNode n, RealVector v) { Color c = Color.WHITE; if (n instanceof TransformNode) { //v = ((TransformNode) n).getTrasformMatrix().getColumnVector(3); v = ((TransformNode) n).getTrasformMatrix().operate(v); //stroke(0, 0, 255); // line((float) bef[0] * scale, (float) bef[1] * scale, (float) bef[2] * scale, (float) att[0] * scale, (float) att[1] * scale, (float) att[2] * scale); c = Color.BLACK;/*from ww w . j ava 2s. c om*/ } else if (n instanceof StaticMesh) { StaticMesh sm = (StaticMesh) n; if (sm.isTransparent()) { c = Color.BLUE; } else if (sm.isVisible()) { // System.out.println(n.getInfo()); // System.out.println(v); c = Color.RED; if (sm.getModel().contains("naohead") || sm.getModel().contains("naobody")) { c = Color.PINK; } } else { c = Color.CYAN; } } else if (n instanceof StaticMeshNode) { StaticMeshNode smn = (StaticMeshNode) n; if (smn.isTransparent()) { c = Color.GREEN; // cameraSceneX = (float)v.getEntry(0); // cameraSceneY = (float)v.getEntry(1); // cameraSceneZ = (float)v.getEntry(2); } else if (smn.isVisible()) { c = Color.YELLOW; } else { c = Color.MAGENTA; } } // if (n.getInfo().contains("naohead")){ // c = Color.CYAN; // pushMatrix(); // fill(c.getRed(), c.getGreen(), c.getBlue()); // // noStroke(); // translate((float) (scale * v.getEntry(0)), (float) (-scale * v.getEntry(1)), (float) (scale * v.getEntry(2))); // box(50); // popMatrix(); // } pushMatrix(); fill(c.getRed(), c.getGreen(), c.getBlue()); noStroke(); translate((float) (scale * v.getEntry(0)), (float) (-scale * v.getEntry(1)), (float) (scale * v.getEntry(2))); box(0.05f * scale); popMatrix(); if (n.getAddress() == selected) { path.add(v); pushMatrix(); fill(0, 255, 255, selectedAlpha); selectedAlpha += (selectedAlpha >= 255) ? -255 : 10; noStroke(); translate((float) (scale * v.getEntry(0)), (float) (-scale * v.getEntry(1)), (float) (scale * v.getEntry(2))); pushMatrix(); //rotateX(t); rotateZ(selectedTheta); selectedTheta += 1 / 8f; box(0.1f * scale); popMatrix(); // info rotateZ(PI / 2); rotateX(-PI / 2); translate(0.1f * scale, -0.1f * scale); fill(0); textSize(0.1f * scale); text(n.getInfo(), 0, 0, 0); popMatrix(); RealVector ant = null; int o = 0; for (RealVector w : path) { if (ant != null) { stroke(o, 255 - o, 0, 200); // System.out.println(ant); // System.out.println(w); line((float) ant.getEntry(0) * scale, (float) ant.getEntry(1) * -scale, (float) ant.getEntry(2) * scale, (float) w.getEntry(0) * scale, (float) w.getEntry(1) * -scale, (float) w.getEntry(2)); o += (o >= 255) ? -200 : 10; } ant = w; pushMatrix(); stroke(255, 255, 0, 200); translate((float) (scale * w.getEntry(0)), (float) (-scale * w.getEntry(1)), (float) (scale * w.getEntry(2))); box(2); popMatrix(); } } for (int a = n.getChildren().size() - 1; a >= 0; a--) { drawTree(((ArrayList<BaseNode>) n.getChildren()).get(a), v); } }
From source file:de.fhbingen.wbs.wpOverview.tabs.AvailabilityGraph.java
/** * Creates a chart of the actual view with a title. * @param title// w w w . ja va2s . c o m * The title of the chart. */ protected final void makeChart(final String title) { DateTickUnit tick = null; switch (actualView) { case DAY: tick = new DateTickUnit(DateTickUnitType.HOUR, 1, new SimpleDateFormat("HH")); break; case WEEK: tick = new DateTickUnit(DateTickUnitType.DAY, 1, new SimpleDateFormat("E, dd.MM.")); break; case MONTH: tick = new DateTickUnit(DateTickUnitType.DAY, 1, new SimpleDateFormat("d.")); break; case YEAR: tick = new DateTickUnit(DateTickUnitType.MONTH, 1, new SimpleDateFormat("M")); break; default: break; } gui.pnlGraph.setChart(ChartFactory.createGanttChart(title, "", "", createDataset(), true, true, false)); gui.pnlGraph.getChart().getTitle().setHorizontalAlignment(HorizontalAlignment.LEFT); gui.pnlGraph.getChart().getTitle().setMargin(5, 10, 5, 5); gui.pnlGraph.getChart().getCategoryPlot().getDomainAxis().setCategoryMargin(0.4); gui.pnlGraph.getChart().getCategoryPlot().getDomainAxis().setLowerMargin(0); gui.pnlGraph.getChart().getCategoryPlot().getDomainAxis().setUpperMargin(0); // chart.getCategoryPlot().getDomainAxis().getL gui.pnlGraph.getChart().getCategoryPlot().getDomainAxis() .setTickLabelFont(new Font(Font.SANS_SERIF, Font.PLAIN, 10)); CategoryPlot plot = gui.pnlGraph.getChart().getCategoryPlot(); DateAxis axis = (DateAxis) plot.getRangeAxis(); axis.setMinimumDate(actualStart.getTime()); axis.setMaximumDate(actualEnd.getTime()); axis.setTickUnit(tick); CategoryItemRenderer renderer = plot.getRenderer(); renderer.setSeriesPaint(0, Color.blue); renderer.setSeriesPaint(1, Color.green); renderer.setSeriesPaint(2, Color.red); }
From source file:gov.llnl.lc.infiniband.opensm.plugin.gui.chart.PortCounterPlotWorker.java
@Override protected Void doInBackground() throws Exception { // 1. counter value (already done, just add following to this) // 2. delta/period ////from w w w . ja v a2 s . com // -- if error counter -- // 3. include xmit and rcv traffic deltas? (own scale) // // // -- if traffic counter -- // 3. include rate and utilization values? // // this is a SwingWorker thread from its pool, give it a recognizable name Thread.currentThread().setName("PortCounterPlotWorker"); logger.info("Worker Building Plot"); SMT_UpdateService updateService = SMT_UpdateService.getInstance(); OMS_Collection history = updateService.getCollection(); OSM_FabricDeltaCollection deltaHistory = history.getOSM_FabricDeltaCollection(); XYPlot plot = (XYPlot) Chart.getPlot(); // AXIS 2 - the change, or delta value of the desired counter NumberAxis axis2 = new NumberAxis(PortCounterAxisLabel.DELTA.getName()); axis2.setFixedDimension(10.0); axis2.setAutoRangeIncludesZero(false); plot.setRangeAxis(1, axis2); XYDataset dataset2 = createDeltaDataset(deltaHistory, PortCounter, PortCounterAxisLabel.DELTA.getName()); plot.setDataset(1, dataset2); plot.mapDatasetToRangeAxis(1, 1); XYItemRenderer renderer2 = new StandardXYItemRenderer(); plot.setRenderer(1, renderer2); // the other two axis are optional, and vary depending on the // type of counter NumberAxis axis3 = null; XYDataset dataset3 = null; XYItemRenderer renderer3 = null; NumberAxis axis4 = null; XYDataset dataset4 = null; XYItemRenderer renderer4 = null; if (AddExtra) { if (isError) { // add rcv deltas PortCounterName pcr = PortCounterName.rcv_data; axis3 = new NumberAxis(PortCounterAxisLabel.RCV_DELTA.getName()); axis3.setFixedDimension(10.0); axis3.setAutoRangeIncludesZero(false); plot.setRangeAxis(2, axis3); dataset3 = createDeltaDataset(deltaHistory, pcr, pcr.getName()); plot.setDataset(2, dataset3); plot.mapDatasetToRangeAxis(2, 2); renderer3 = new StandardXYItemRenderer(); plot.setRenderer(2, renderer3); // add xmit deltas pcr = PortCounterName.xmit_data; axis4 = new NumberAxis(PortCounterAxisLabel.XMT_DELTA.getName()); axis4.setFixedDimension(10.0); axis4.setAutoRangeIncludesZero(false); plot.setRangeAxis(3, axis4); dataset4 = createDeltaDataset(deltaHistory, pcr, pcr.getName()); plot.setDataset(3, dataset4); plot.mapDatasetToRangeAxis(3, 3); renderer4 = new StandardXYItemRenderer(); plot.setRenderer(3, renderer4); // use a common scale for both xmit and rcv counters double minRange = axis3.getLowerBound() < axis4.getLowerBound() ? axis3.getLowerBound() : axis4.getLowerBound(); double maxRange = axis3.getUpperBound() < axis4.getUpperBound() ? axis4.getUpperBound() : axis3.getUpperBound(); axis3.setAutoRange(false); axis4.setAutoRange(false); axis3.setRange(minRange, maxRange); axis4.setRange(minRange, maxRange); } else { // add rate PortCounterName pcr = PortCounter; axis3 = new NumberAxis(pcr.getName() + " " + PortCounterAxisLabel.RATE.getUnits()); axis3.setFixedDimension(10.0); axis3.setAutoRangeIncludesZero(true); plot.setRangeAxis(2, axis3); dataset3 = createRateDataset(deltaHistory, pcr, PortCounterAxisLabel.RATE.getName()); plot.setDataset(2, dataset3); plot.mapDatasetToRangeAxis(2, 2); renderer3 = new StandardXYItemRenderer(); plot.setRenderer(2, renderer3); // add utilization axis4 = new NumberAxis(pcr.getName() + " " + PortCounterAxisLabel.UTILIZATION.getUnits()); axis4.setFixedDimension(10.0); // axis4.setAutoRangeIncludesZero(true); axis4.setRange(0.0, 100.0); plot.setRangeAxis(3, axis4); dataset4 = createUtilizationDataset(deltaHistory, pcr, PortCounterAxisLabel.UTILIZATION.getName()); plot.setDataset(3, dataset4); plot.mapDatasetToRangeAxis(3, 3); renderer4 = new StandardXYItemRenderer(); plot.setRenderer(3, renderer4); } } ChartUtilities.applyCurrentTheme(Chart); Color c1 = Color.black; Color c2 = Color.blue; Color c3 = Color.green; Color c4 = Color.magenta; Color ce = Color.red; if (isError) c2 = ce; // change the series and axis colours after the theme has // been applied... plot.getRenderer().setSeriesPaint(0, c1); renderer2.setSeriesPaint(0, c2); axis2.setLabelPaint(c2); axis2.setTickLabelPaint(c2); if (AddExtra) { renderer3.setSeriesPaint(0, c3); axis3.setLabelPaint(c3); axis3.setTickLabelPaint(c3); renderer4.setSeriesPaint(0, c4); axis4.setLabelPaint(c4); axis4.setTickLabelPaint(c4); } return null; }
From source file:de.tor.tribes.ui.views.DSWorkbenchDoItYourselfAttackPlaner.java
@Override public void resetView() { AttackManager.getSingleton().addManagerListener(this); //setup renderer and general view // ((DoItYourselfAttackTableModel) jAttackTable.getModel()).clear(); HighlightPredicate.ColumnHighlightPredicate colu = new HighlightPredicate.ColumnHighlightPredicate(0, 1, 2, 3, 6);/*from ww w . ja va 2s .c o m*/ jAttackTable.setRowHeight(24); jAttackTable.getTableHeader().setDefaultRenderer(new DefaultTableHeaderRenderer()); jAttackTable.setHighlighters(new CompoundHighlighter(colu, HighlighterFactory.createAlternateStriping(Constants.DS_ROW_A, Constants.DS_ROW_B))); jAttackTable.setColumnControlVisible(true); jAttackTable.setDefaultEditor(UnitHolder.class, new UnitCellEditor()); jAttackTable.setDefaultEditor(Village.class, new VillageCellEditor()); jAttackTable.setDefaultRenderer(UnitHolder.class, new UnitCellRenderer()); jAttackTable.setDefaultRenderer(Integer.class, new NoteIconCellRenderer(NoteIconCellRenderer.ICON_TYPE.NOTE)); jAttackTable.setDefaultRenderer(Date.class, new ColoredDateCellRenderer()); jAttackTable.setDefaultRenderer(Long.class, new ColoredCoutdownCellRenderer()); jAttackTable.setDefaultEditor(Date.class, new DateSpinEditor()); jAttackTable.setDefaultEditor(Integer.class, new NoteIconCellEditor(NoteIconCellEditor.ICON_TYPE.NOTE)); BufferedImage back = ImageUtils.createCompatibleBufferedImage(5, 5, BufferedImage.BITMASK); Graphics2D g = back.createGraphics(); GeneralPath p = new GeneralPath(); p.moveTo(0, 0); p.lineTo(5, 0); p.lineTo(5, 5); p.closePath(); g.setColor(Color.GREEN.darker()); g.fill(p); g.dispose(); jAttackTable.addHighlighter(new PainterHighlighter(HighlightPredicate.EDITABLE, new ImagePainter(back, HorizontalAlignment.RIGHT, VerticalAlignment.TOP))); DefaultComboBoxModel model = new DefaultComboBoxModel(); DefaultComboBoxModel model2 = new DefaultComboBoxModel(); for (UnitHolder unit : DataHolder.getSingleton().getUnits()) { model.addElement(unit); model2.addElement(unit); } jUnitBox.setModel(model); jUnitComboBox.setModel(model2); jUnitBox.setSelectedItem(DataHolder.getSingleton().getUnitByPlainName("ram")); jUnitComboBox.setSelectedItem(DataHolder.getSingleton().getUnitByPlainName("ram")); jUnitBox.setRenderer(new UnitListCellRenderer()); jAttackTypeComboBox.setRenderer(new StandardAttackListCellRenderer()); DefaultComboBoxModel typeModel = new DefaultComboBoxModel(); for (ManageableType t : StandardAttackManager.getSingleton().getAllElements()) { StandardAttack a = (StandardAttack) t; typeModel.addElement(a); } jAttackTypeComboBox.setModel(typeModel); jUnitComboBox.setRenderer(new UnitListCellRenderer()); jSourceVillage.setValue(new Point(500, 500)); jTargetVillage.setValue(new Point(500, 500)); SwingUtilities.invokeLater(new Runnable() { @Override public void run() { jSourceVillage.updateUI(); jTargetVillage.updateUI(); } }); }
From source file:ecg.ecgshow.ECGShowUI.java
private void createPressureData(long timeZone) { PressureData = new JPanel(); PressuredateAxises = new DateAxis[1]; SystolicPressureSeries = new TimeSeries[2]; DiastolicPressureSeries = new TimeSeries[2]; TimeSeriesCollection timeseriescollection = new TimeSeriesCollection(); SystolicPressureSeries[0] = new TimeSeries(""); SystolicPressureSeries[0].setMaximumItemAge(timeZone); SystolicPressureSeries[0].setMaximumItemCount(500); SystolicPressureSeries[1] = new TimeSeries(""); SystolicPressureSeries[1].setMaximumItemAge(timeZone); SystolicPressureSeries[1].setMaximumItemCount(2); timeseriescollection.addSeries(SystolicPressureSeries[0]); timeseriescollection.addSeries(SystolicPressureSeries[1]); PressuredateAxises[0] = new DateAxis(""); PressuredateAxises[0].setTickLabelFont(new Font("SansSerif", 0, (int) (HEIGHT * 0.016))); PressuredateAxises[0].setLabelFont(new Font("SansSerif", 0, (int) (HEIGHT * 0.018))); PressuredateAxises[0].setTickLabelsVisible(true); PressuredateAxises[0].setVisible(false); DiastolicPressureSeries[0] = new TimeSeries(""); DiastolicPressureSeries[0].setMaximumItemAge(timeZone); DiastolicPressureSeries[0].setMaximumItemCount(500); DiastolicPressureSeries[1] = new TimeSeries(""); DiastolicPressureSeries[1].setMaximumItemAge(timeZone); DiastolicPressureSeries[1].setMaximumItemCount(2); timeseriescollection.addSeries(DiastolicPressureSeries[0]); timeseriescollection.addSeries(DiastolicPressureSeries[1]); NumberAxis numberaxis = new NumberAxis("Pressure"); numberaxis.setTickLabelFont(new Font("SansSerif", 0, (int) (HEIGHT * 0.016))); numberaxis.setLabelFont(new Font("SansSerif", 0, (int) (HEIGHT * 0.018))); numberaxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); numberaxis.setVisible(false);//from w ww . jav a2 s . co m numberaxis.setLowerBound(0D); numberaxis.setUpperBound(200D); XYLineAndShapeRenderer xylineandshaperenderer = new XYLineAndShapeRenderer(true, false); xylineandshaperenderer.setSeriesPaint(0, Color.GREEN); // xylineandshaperenderer.setSeriesStroke(0, new BasicStroke(2)); // xylineandshaperenderer.setSeriesPaint(1, Color.LIGHT_GRAY); // xylineandshaperenderer.setSeriesStroke(1, new BasicStroke(5)); xylineandshaperenderer.setSeriesPaint(2, Color.ORANGE); // xylineandshaperenderer.setSeriesStroke(2, new BasicStroke(2)); // xylineandshaperenderer.setSeriesPaint(3, Color.LIGHT_GRAY); // xylineandshaperenderer.setSeriesStroke(3, new BasicStroke(5)); //XYPlot xyplot = new XYPlot(timeseriescollection, PressuredateAxises[0], numberaxis, xylineandshaperenderer); XYPlot xyplot = new XYPlot(timeseriescollection, dateAxises[0], numberaxis, xylineandshaperenderer); xyplot.setBackgroundPaint(Color.LIGHT_GRAY); xyplot.setDomainGridlinePaint(Color.LIGHT_GRAY); xyplot.setRangeGridlinePaint(Color.LIGHT_GRAY); xyplot.setAxisOffset(new RectangleInsets(5D, 5D, 5D, 5D)); xyplot.setBackgroundPaint(Color.BLACK); JFreeChart jfreechart = new JFreeChart(xyplot); jfreechart.setBackgroundPaint(new Color(237, 237, 237));//? jfreechart.getLegend().setVisible(false); ChartPanel chartpanel = new ChartPanel(jfreechart, (int) (WIDTH * 0.155), (int) (HEIGHT * 0.18), 0, 0, Integer.MAX_VALUE, Integer.MAX_VALUE, true, true, false, true, false, false); chartpanel.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0) //??0 , BorderFactory.createEmptyBorder() //???? )); chartpanel.setMouseZoomable(false); PressureData.add(chartpanel); }
From source file:coolmap.canvas.datarenderer.renderer.impl.NumberToColor.java
public NumberToColor() { setName("Number to Color"); setDescription("Use color to represent numeric values"); //initialize UI configUI.setLayout(new GridBagLayout()); GridBagConstraints c = new GridBagConstraints(); c.fill = GridBagConstraints.HORIZONTAL; c.gridx = 0;//from w ww .j ava 2 s . c o m c.gridy = 0; c.ipadx = 5; c.ipady = 5; c.insets = new Insets(5, 5, 5, 5); c.gridwidth = 2; // c.weightx = 0.8; editor = new GradientEditorPanel(); configUI.add(editor, c); c.gridx = 0; c.gridy++; c.gridwidth = 1; // JButton button = new JButton("Apply"); // configUI.add(button, c); // button.setToolTipText("Apply preset gradient"); // // button.addActionListener(new ActionListener() { // // @Override // public void actionPerformed(ActionEvent e) { // // try { // GradientItem item = (GradientItem) presetColorComboBox.getSelectedItem(); // // editor.clearColors(); // // Color c[] = item.getColors(); // float p[] = item.getPositions(); // // editor.setStart(c[0]); // editor.setEnd(c[c.length - 1]); // // if (c.length > 2) { // for (int i = 1; i < c.length - 1; i++) { // editor.addColor(c[i], p[i]); // } // } // // } catch (Exception ex) { // editor.clearColors(); // editor.setStart(DEFAULT_MIN_COLOR); // editor.setEnd(DEFAULT_MAX_COLOR); // } // // updateRenderer(); // } // }); configUI.add(new JLabel("Preset palette:"), c); c.gridx = 1; c.gridwidth = 1; presetColorComboBox = new JComboBox(); presetColorComboBox.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { try { GradientItem item = (GradientItem) presetColorComboBox.getSelectedItem(); presetColorComboBox.setToolTipText(item.getToolTip()); editor.clearColors(); Color c[] = item.getColors(); float p[] = item.getPositions(); editor.setStart(c[0]); editor.setEnd(c[c.length - 1]); if (c.length > 2) { for (int i = 1; i < c.length - 1; i++) { editor.addColor(c[i], p[i]); } } try { Double[] ranges = item.getRanges(); if (ranges != null) { minValueField.setText(ranges[0].toString()); maxValueField.setText(ranges[1].toString()); editor.setMinValue(ranges[0].floatValue()); editor.setMaxValue(ranges[1].floatValue()); } } catch (Exception ex) { minValueField.setText("-1"); maxValueField.setText("1"); editor.setMinValue(-1); editor.setMaxValue(1); } } catch (Exception ex) { editor.clearColors(); editor.setStart(DEFAULT_MIN_COLOR); editor.setEnd(DEFAULT_MAX_COLOR); } } }); // configUI.add(presetColorComboBox, c); presetColorComboBox.setRenderer(new GradientComboItemRenderer()); presetColorComboBox .addItem(new GradientItem(new Color[] { DEFAULT_MIN_COLOR, Color.BLACK, DEFAULT_MAX_COLOR }, new float[] { 0f, 0.5f, 1f }, "TBP", "Teal - Black - Pink")); presetColorComboBox.addItem(new GradientItem(new Color[] { Color.GREEN, Color.RED }, new float[] { 0f, 1f }, "GR", "Green - Red")); presetColorComboBox.addItem(new GradientItem(new Color[] { Color.GREEN, Color.BLACK, Color.RED }, new float[] { 0f, 0.5f, 1f }, "RBG", "Red - Black - Green")); presetColorComboBox.addItem(new GradientItem(new Color[] { Color.ORANGE, Color.BLUE }, new float[] { 0f, 1f }, "OB", "Orange - Blue")); presetColorComboBox.addItem(new GradientItem(new Color[] { Color.ORANGE, Color.BLACK, Color.BLUE }, new float[] { 0f, 0.5f, 1f }, "OBB", "Orange - Black - Blue")); presetColorComboBox.addItem(new GradientItem(new Color[] { Color.BLACK, Color.GREEN }, new float[] { 0f, 1f }, "BG", "Black - Green")); presetColorComboBox .addItem(new GradientItem(new Color[] { Color.RED, UI.colorAKABENI, Color.BLACK, Color.BLACK }, new float[] { 0f, 0.05f, 0.051f, 1f }, "P.05", 0d, 1d, "P-value @ 0.05, Red to Black")); presetColorComboBox.setToolTipText(((GradientItem) presetColorComboBox.getSelectedItem()).getToolTip()); c.gridx = 0; c.gridy++; c.gridwidth = 1; // button = new JButton("Apply"); // // button.setToolTipText("Apply preset data ranges"); // button.addActionListener(new ActionListener() { // // @Override // public void actionPerformed(ActionEvent e) { // try { // MinMaxItem item = (MinMaxItem) (presetRangeComboBox.getSelectedItem()); // minValueField.setText(item.getMinMax().lowerEndpoint().toString()); // maxValueField.setText(item.getMinMax().upperEndpoint().toString()); // } catch (Exception ex) { // minValueField.setText("-1"); // maxValueField.setText("1"); // } // // updateRenderer(); // } // }); // configUI.add(button, c); configUI.add(new JLabel("Preset range:"), c); c.gridx = 1; c.gridwidth = 1; presetRangeComboBox = new JComboBox(); configUI.add(presetRangeComboBox, c); presetRangeComboBox.addItem(new DataMinMaxItem()); presetRangeComboBox.addItem(new DefinedMinMaxItem(-1, 1)); presetRangeComboBox.addItem(new DefinedMinMaxItem(0, 1)); presetRangeComboBox.addItem(new DefinedMinMaxItem(-1, 0)); presetRangeComboBox.addItem(new DefinedMinMaxItem(0, 100)); presetRangeComboBox.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { try { MinMaxItem item = (MinMaxItem) (presetRangeComboBox.getSelectedItem()); minValueField.setText(item.getMinMax().lowerEndpoint().toString()); maxValueField.setText(item.getMinMax().upperEndpoint().toString()); } catch (Exception ex) { minValueField.setText("-1"); maxValueField.setText("1"); } } }); //////////////////////////////////////////////////////////////////////////////// // c.weightx = 0.2; c.gridx = 0; c.gridy++; c.gridwidth = 1; configUI.add(new JLabel("Min value: "), c); c.gridx = 1; // c.weightx = 0.3; configUI.add(minValueField, c); c.gridx = 0; c.gridy++; c.gridwidth = 1; configUI.add(new JLabel("Max value: "), c); c.gridx = 1; configUI.add(maxValueField, c); c.gridx = 0; c.gridy++; c.gridwidth = 1; JLabel label = Tools.createJLabel("Draw Sub-heatmap:", null, "Draw sub-heatmaps for collapsed ontology nodes", null); configUI.add(label, c); c.gridx = 1; drawSubMap = new JCheckBox(); configUI.add(drawSubMap, c); c.gridx = 0; c.gridy++; c.gridwidth = 3; JButton button = new JButton("Update", UI.getImageIcon("refresh")); configUI.add(button, c); button.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { //hit button, redraw! updateRenderer(); } }); // editor.applyButton.addActionListener(new ActionListener() { // // @Override // public void actionPerformed(ActionEvent e) { // updateRenderer(); // } // }); toolTipLabel = new JLabel(); toolTipLabel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); toolTipLabel.setBackground(UI.colorGrey3); toolTipLabel.setOpaque(true); toolTipLabel.setForeground(UI.colorBlack2); toolTipLabel.setFont(UI.fontPlain.deriveFont(12f)); }
From source file:piilSource.BarChart.java
private JFreeChart createChart(String title, final CategoryDataset dataset, String metaLabel) { // create the chart... final JFreeChart chart = ChartFactory.createBarChart( "Barplot of the " + metaLabel + " values for all samples - " + title, // chart title "Samples", // domain axis label metaLabel + " values", // range axis label dataset, // data PlotOrientation.VERTICAL, // orientation true, // include legend true, // tooltips? false // URLs? );// www . jav a 2 s . c o m // set the background color for the chart... chart.setBackgroundPaint(Color.white); // get a reference to the plot for further customisation... final CategoryPlot plot = chart.getCategoryPlot(); plot.setBackgroundPaint(Color.lightGray); plot.setDomainGridlinePaint(Color.red); plot.setRangeGridlinePaint(Color.white); // set the range axis to display integers only... final NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); if (metaLabel.equals("beta")) { rangeAxis.setRange(0, 1); rangeAxis.setTickUnit(new NumberTickUnit(0.2)); } // disable bar outlines... final BarRenderer renderer = (BarRenderer) plot.getRenderer(); renderer.setDrawBarOutline(false); // set up gradient paints for series... final GradientPaint gp0 = new GradientPaint(0.0f, 0.0f, Color.blue, 0.0f, 0.0f, Color.blue); final GradientPaint gp1 = new GradientPaint(0.0f, 0.0f, Color.green, 0.0f, 0.0f, Color.green); final GradientPaint gp2 = new GradientPaint(0.0f, 0.0f, Color.red, 0.0f, 0.0f, Color.red); final GradientPaint gp3 = new GradientPaint(0.0f, 0.0f, Color.yellow, 0.0f, 0.0f, Color.yellow); final GradientPaint gp4 = new GradientPaint(0.0f, 0.0f, Color.cyan, 0.0f, 0.0f, Color.cyan); renderer.setSeriesPaint(0, gp0); renderer.setSeriesPaint(1, gp1); renderer.setSeriesPaint(2, gp2); renderer.setSeriesPaint(3, gp3); renderer.setSeriesPaint(4, gp4); final CategoryAxis domainAxis = plot.getDomainAxis(); domainAxis.setCategoryLabelPositions(CategoryLabelPositions.createUpRotationLabelPositions(Math.PI / 6.0)); if (dataset.getColumnCount() > 40) { domainAxis.setTickLabelFont(new Font("Serif", Font.PLAIN, 10)); domainAxis .setCategoryLabelPositions(CategoryLabelPositions.createUpRotationLabelPositions(Math.PI / 2)); } return chart; }
From source file:org.openscience.cdk.applications.taverna.basicutilities.ChartTool.java
/** * Creates a line chart.//w w w.jav a 2s. c o m * * @param title * @param categoryAxisLabel * (X-Axis label) * @param valueAxisLabel * (Y-Axis label) * @param dataset * @param includeZero * True when zero shall be included to the axis range. * @return JfreeChart instance. */ public JFreeChart createLineChart(String title, String categoryAxisLabel, String valueAxisLabel, CategoryDataset dataset, boolean includeZero, boolean drawShapes) { JFreeChart chart = ChartFactory.createLineChart(title, categoryAxisLabel, valueAxisLabel, dataset, this.orientation, this.drawLegend, false, false); // set the background color for the chart... chart.setBackgroundPaint(Color.white); chart.setAntiAlias(true); CategoryPlot plot = chart.getCategoryPlot(); CategoryAxis domainAxis = plot.getDomainAxis(); domainAxis.setLowerMargin(0.025); domainAxis.setUpperMargin(0.025); domainAxis.setCategoryLabelPositions(CategoryLabelPositions.DOWN_90); NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setAutoRangeIncludesZero(includeZero); LineAndShapeRenderer renderer = (LineAndShapeRenderer) plot.getRenderer(); renderer.setSeriesPaint(0, Color.blue); renderer.setSeriesPaint(1, Color.red); renderer.setSeriesPaint(2, Color.green); renderer.setSeriesPaint(3, Color.darkGray); renderer.setSeriesPaint(4, Color.yellow); renderer.setDrawOutlines(true); renderer.setUseFillPaint(true); renderer.setBaseShapesVisible(drawShapes); renderer.setBaseShapesFilled(true); return chart; }
From source file:de.tor.tribes.ui.algo.TimeFrameVisualizer.java
private void renderRange(LongRange pRange, LongRange pStartRange, LongRange pArriveRange, boolean pIsStartRange, boolean pIsArriveRange, Graphics2D pG2D, TimeSpan pSpanForRange, HashMap<String, Object> pPopupInfo) { int rangeStart = 0; int rangeWidth = 0; if (pRange.overlapsRange(pStartRange)) { //start range rendering long startDelta = pStartRange.getMinimumLong(); rangeStart = Math.round((pRange.getMinimumLong() - startDelta) / DateUtils.MILLIS_PER_MINUTE); // int rangeEnd = Math.round((pRange.getMaximumLong() - startDelta) / DateUtils.MILLIS_PER_MINUTE); rangeWidth = Math/* ww w.j a v a 2 s .c om*/ .round((pRange.getMaximumLong() - pRange.getMinimumLong()) / DateUtils.MILLIS_PER_MINUTE); } else if (pRange.overlapsRange(pArriveRange)) { //end range rendering long startDelta = pStartRange.getMinimumLong(); rangeStart = Math.round((pRange.getMinimumLong() - startDelta) / DateUtils.MILLIS_PER_MINUTE); // int rangeEnd = Math.round((pRange.getMaximumLong() - arriveDelta) / DateUtils.MILLIS_PER_MINUTE); rangeWidth = Math .round((pRange.getMaximumLong() - pRange.getMinimumLong()) / DateUtils.MILLIS_PER_MINUTE); } //correct small widths if (rangeWidth == 0) { rangeWidth = 5; } long max = Math.round( (pArriveRange.getMaximumLong() - pStartRange.getMinimumLong()) / DateUtils.MILLIS_PER_MINUTE); if (rangeStart > max) { return; } SimpleDateFormat f = new SimpleDateFormat("dd.MM.yy HH:mm:ss"); String labelString = ""; if (pSpanForRange != null) { labelString = pSpanForRange.toString(); } else { labelString = f.format(new Date(pRange.getMinimumLong())) + " bis " + f.format(new Date(pRange.getMaximumLong())); } Rectangle2D labelBounds = pG2D.getFontMetrics().getStringBounds(labelString, pG2D); if (pIsStartRange) { pG2D.setColor(Color.RED); pG2D.fillRect(rangeStart, 20, rangeWidth, 20); pG2D.setColor(Color.BLACK); pG2D.drawRect(rangeStart, 20, rangeWidth, 20); pG2D.setColor(Color.RED); pG2D.setFont(pG2D.getFont().deriveFont(Font.BOLD, 14.0f)); pG2D.drawString(labelString, rangeStart, (int) labelBounds.getHeight()); } else if (pIsArriveRange) { pG2D.setColor(Color.GREEN.darker()); pG2D.fillRect(rangeStart, 20, rangeWidth, 20); pG2D.setColor(Color.BLACK); pG2D.drawRect(rangeStart, 20, rangeWidth, 20); pG2D.setColor(Color.GREEN.darker()); pG2D.setFont(pG2D.getFont().deriveFont(Font.BOLD, 14.0f)); pG2D.drawString(labelString, rangeStart, (int) labelBounds.getHeight() + 40); } else { pG2D.fillRect(rangeStart, 20, rangeWidth, 20); pG2D.setColor(Color.BLACK); pG2D.drawRect(rangeStart, 20, rangeWidth, 20); Point loc = getMousePosition(); if (loc != null && new Rectangle(rangeStart, 20, rangeWidth, 20).contains(loc)) { pPopupInfo.put("popup.location", loc); pPopupInfo.put("popup.label", labelString); pPopupInfo.put("active.range", pRange); pPopupInfo.put("span.for.range", pSpanForRange); } } }