List of usage examples for java.awt Color cyan
Color cyan
To view the source code for java.awt Color cyan.
Click Source Link
From source file:net.sf.dynamicreports.test.jasper.chart.GanttChartTest.java
@Override public void test() { super.test(); numberOfPagesTest(1);/*from w ww . ja v a 2s . c om*/ JFreeChart chart = getChart("summary.chart1", 0); CategoryPlot categoryPlot = chart.getCategoryPlot(); Assert.assertEquals("renderer", GanttRenderer.class, categoryPlot.getRenderer().getClass()); Assert.assertTrue("show labels", categoryPlot.getRenderer().getBaseItemLabelsVisible()); Assert.assertFalse("show tick labels", categoryPlot.getDomainAxis().isTickMarksVisible()); Assert.assertFalse("show tick marks", categoryPlot.getDomainAxis().isTickLabelsVisible()); ganttChartDataTest(chart, "label", new String[] { "task1", "task2", "task3" }, new Object[][] { { toDate(2011, 1, 1), toDate(2011, 1, 8), 1d }, { toDate(2011, 1, 10), toDate(2011, 1, 15), 0.5d }, { toDate(2011, 1, 15), toDate(2011, 1, 25), 0.8d } }); ganttChartDataTest(chart, "serie1", new String[] { "task1", "task2", "task3" }, new Object[][] { { toDate(2011, 1, 2), toDate(2011, 1, 9), null }, { toDate(2011, 1, 8), toDate(2011, 1, 14), null }, { toDate(2011, 1, 16), toDate(2011, 1, 20), null } }); chart = getChart("summary.chart2", 0); Axis axis = chart.getCategoryPlot().getDomainAxis(); Assert.assertEquals("task label", "task", axis.getLabel()); Assert.assertEquals("task label color", Color.BLUE, axis.getLabelPaint()); Assert.assertEquals("task label font", new Font("Arial", Font.BOLD, 10), axis.getLabelFont()); Assert.assertEquals("tick label color", Color.CYAN, axis.getTickLabelPaint()); Assert.assertEquals("tick label font", new Font("Arial", Font.ITALIC, 10), axis.getTickLabelFont()); CategoryLabelPosition labelPosition = chart.getCategoryPlot().getDomainAxis().getCategoryLabelPositions() .getLabelPosition(RectangleEdge.LEFT); Assert.assertEquals("plot label rotation", (45d / 180) * Math.PI, labelPosition.getAngle()); Assert.assertEquals("line color", Color.LIGHT_GRAY, axis.getAxisLinePaint()); chart = getChart("summary.chart3", 0); axis = chart.getCategoryPlot().getRangeAxis(); Assert.assertEquals("time label", "time", axis.getLabel()); Assert.assertEquals("time label color", Color.BLUE, axis.getLabelPaint()); Assert.assertEquals("time label font", new Font("Arial", Font.BOLD, 10), axis.getLabelFont()); Assert.assertEquals("tick label color", Color.CYAN, axis.getTickLabelPaint()); Assert.assertEquals("tick label font", new Font("Arial", Font.ITALIC, 10), axis.getTickLabelFont()); Assert.assertEquals("line color", Color.LIGHT_GRAY, axis.getAxisLinePaint()); }
From source file:playground.sergioo.facilitiesGenerator2012.gui.ClustersPanel.java
public ClustersPanel(ClustersWindow window, List<CentroidCluster<PointPerson>> clusters, int numTotalPoints) { super();/*ww w.j ava2 s .co m*/ this.window = window; for (CentroidCluster<PointPerson> cluster : clusters) { Color color = new Color((float) (Math.random() * 0.5), (float) (Math.random() * 0.5), (float) (Math.random() * 0.5)); //Color color = new Color(5.5f*(float)(cluster.getPoints().size())/numTotalPoints, 5.5f*(float)(cluster.getPoints().size())/numTotalPoints, 5.5f*(float)(cluster.getPoints().size())/numTotalPoints); PointsPainter pointsPainter = new PointsPainter(color); for (PointPerson point : cluster.getPoints()) pointsPainter.addPoint(new CoordImpl(point.getElement(0), point.getElement(1))); addLayer(new Layer(pointsPainter)); } this.setBackground(Color.CYAN); calculateBoundaries(); super.setPreferredSize(Toolkit.getDefaultToolkit().getScreenSize().width, Toolkit.getDefaultToolkit().getScreenSize().height); addMouseListener(this); addMouseMotionListener(this); addMouseWheelListener(this); addKeyListener(this); setFocusable(true); }
From source file:j2se.jfreechart.barchart.BarChartDemo3.java
/** * Creates a sample chart.//from w w w.ja v a2s . c om * * @param dataset the dataset. * * @return a sample chart. */ private JFreeChart createChart(final CategoryDataset dataset) { final JFreeChart chart = ChartFactory.createBarChart("Bar Chart Demo 3", // chart title "Category", // domain axis label "Value", // range axis label dataset, // data PlotOrientation.VERTICAL, // the plot orientation false, // include legend true, false); chart.setBackgroundPaint(Color.lightGray); // get a reference to the plot for further customisation... final CategoryPlot plot = chart.getCategoryPlot(); plot.setNoDataMessage("NO DATA!"); final CategoryItemRenderer renderer = new CustomRenderer(new Paint[] { Color.red, Color.blue, Color.green, Color.yellow, Color.orange, Color.cyan, Color.magenta, Color.blue }); // renderer.setLabelGenerator(new StandardCategoryLabelGenerator()); renderer.setItemLabelsVisible(true); final ItemLabelPosition p = new ItemLabelPosition(ItemLabelAnchor.CENTER, TextAnchor.CENTER, TextAnchor.CENTER, 45.0); renderer.setPositiveItemLabelPosition(p); plot.setRenderer(renderer); // change the margin at the top of the range axis... final ValueAxis rangeAxis = plot.getRangeAxis(); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); rangeAxis.setLowerMargin(0.15); rangeAxis.setUpperMargin(0.15); return chart; }
From source file:umontreal.ssj.charts.SSJCategorySeriesCollection.java
/** * Converts a java Color object into a friendly and readable LaTeX/xcolor string. * * @param color in color./*from w w w . j ava 2 s . c om*/ * @return friendly color with string format as possible, null otherwise. */ protected static String detectXColorClassic(Color color) { String retour = null; int red = color.getRed(); int green = color.getGreen(); int blue = color.getBlue(); // On utilise pas la method Color.equals(Color ) car on ne veut pas tester le parametre de transparence : Alpha if (red == Color.GREEN.getRed() && blue == Color.GREEN.getBlue() && green == Color.GREEN.getGreen()) return "green"; else if (red == Color.RED.getRed() && blue == Color.RED.getBlue() && green == Color.RED.getGreen()) return "red"; else if (red == Color.WHITE.getRed() && blue == Color.WHITE.getBlue() && green == Color.WHITE.getGreen()) return "white"; else if (red == Color.GRAY.getRed() && blue == Color.GRAY.getBlue() && green == Color.GRAY.getGreen()) return "gray"; else if (red == Color.BLACK.getRed() && blue == Color.BLACK.getBlue() && green == Color.BLACK.getGreen()) return "black"; else if (red == Color.YELLOW.getRed() && blue == Color.YELLOW.getBlue() && green == Color.YELLOW.getGreen()) return "yellow"; else if (red == Color.MAGENTA.getRed() && blue == Color.MAGENTA.getBlue() && green == Color.MAGENTA.getGreen()) return "magenta"; else if (red == Color.CYAN.getRed() && blue == Color.CYAN.getBlue() && green == Color.CYAN.getGreen()) return "cyan"; else if (red == Color.BLUE.getRed() && blue == Color.BLUE.getBlue() && green == Color.BLUE.getGreen()) return "blue"; else if (red == Color.DARK_GRAY.getRed() && blue == Color.DARK_GRAY.getBlue() && green == Color.DARK_GRAY.getGreen()) return "darkgray"; else if (red == Color.LIGHT_GRAY.getRed() && blue == Color.LIGHT_GRAY.getBlue() && green == Color.LIGHT_GRAY.getGreen()) return "lightgray"; else if (red == Color.ORANGE.getRed() && blue == Color.ORANGE.getBlue() && green == Color.ORANGE.getGreen()) return "orange"; else if (red == Color.PINK.getRed() && blue == Color.PINK.getBlue() && green == Color.PINK.getGreen()) return "pink"; if (red == 192 && blue == 128 && green == 64) return "brown"; else if (red == 128 && blue == 128 && green == 0) return "olive"; else if (red == 128 && blue == 0 && green == 128) return "violet"; else if (red == 192 && blue == 0 && green == 64) return "purple"; else return null; }
From source file:com.att.aro.ui.view.diagnostictab.plot.NetworkTypePlot.java
private void setRenderingColorForDataSeries(XYItemRenderer renderer, final XYIntervalSeriesCollection dataSeries) { renderer.setSeriesPaint(dataSeries.indexOf(NetworkType.none), Color.WHITE); renderer.setSeriesPaint(dataSeries.indexOf(NetworkType.LTE), Color.RED); renderer.setSeriesPaint(dataSeries.indexOf(NetworkType.WIFI), Color.BLUE); renderer.setSeriesPaint(dataSeries.indexOf(NetworkType.UMTS), Color.PINK); renderer.setSeriesPaint(dataSeries.indexOf(NetworkType.ETHERNET), Color.BLACK); renderer.setSeriesPaint(dataSeries.indexOf(NetworkType.HSDPA), Color.YELLOW); renderer.setSeriesPaint(dataSeries.indexOf(NetworkType.HSPA), Color.ORANGE); renderer.setSeriesPaint(dataSeries.indexOf(NetworkType.HSPAP), Color.MAGENTA); renderer.setSeriesPaint(dataSeries.indexOf(NetworkType.HSUPA), Color.CYAN); renderer.setSeriesPaint(dataSeries.indexOf(NetworkType.GPRS), Color.GRAY); renderer.setSeriesPaint(dataSeries.indexOf(NetworkType.EDGE), Color.LIGHT_GRAY); }
From source file:net.sf.dynamicreports.test.jasper.chart.DifferenceChartTest.java
@Override public void test() { super.test(); numberOfPagesTest(1);//from w ww.ja va 2 s . com JFreeChart chart = getChart("summary.chart1", 0); XYItemRenderer renderer = chart.getXYPlot().getRenderer(); Assert.assertEquals("renderer", XYDifferenceRenderer.class, renderer.getClass()); Assert.assertFalse("show shapes", ((XYDifferenceRenderer) renderer).getShapesVisible()); Assert.assertEquals("positive paint", Color.BLUE, ((XYDifferenceRenderer) renderer).getPositivePaint()); Assert.assertEquals("negative paint", Color.MAGENTA, ((XYDifferenceRenderer) renderer).getNegativePaint()); chart = getChart("summary.chart2", 0); Axis axis = chart.getXYPlot().getDomainAxis(); Assert.assertEquals("category label", "time", axis.getLabel()); Assert.assertEquals("category label color", Color.BLUE, axis.getLabelPaint()); Assert.assertEquals("category label font", new Font("Arial", Font.BOLD, 10), axis.getLabelFont()); Assert.assertEquals("tick label color", Color.CYAN, axis.getTickLabelPaint()); Assert.assertEquals("tick label font", new Font("Arial", Font.ITALIC, 10), axis.getTickLabelFont()); Assert.assertEquals("line color", Color.LIGHT_GRAY, axis.getAxisLinePaint()); Assert.assertTrue("vertical tick labels", ((ValueAxis) axis).isVerticalTickLabels()); chart = getChart("summary.chart3", 0); axis = chart.getXYPlot().getRangeAxis(); Assert.assertEquals("value label", "value", axis.getLabel()); Assert.assertEquals("value label color", Color.BLUE, axis.getLabelPaint()); Assert.assertEquals("value label font", new Font("Arial", Font.BOLD, 10), axis.getLabelFont()); Assert.assertEquals("tick label color", Color.CYAN, axis.getTickLabelPaint()); Assert.assertEquals("tick label font", new Font("Arial", Font.ITALIC, 10), axis.getTickLabelFont()); Assert.assertEquals("tick label mask", "10.00", ((NumberAxis) axis).getNumberFormatOverride().format(10)); //Assert.assertEquals("line color", Color.LIGHT_GRAY, axis.getAxisLinePaint()); Assert.assertEquals("range min value", 1d, ((ValueAxis) axis).getLowerBound()); Assert.assertEquals("range max value", 15d, ((ValueAxis) axis).getUpperBound()); Assert.assertTrue("vertical tick labels", ((ValueAxis) axis).isVerticalTickLabels()); }
From source file:com.google.code.facebook.graph.sna.applet.RadialTreeLensDemo.java
/** * create an instance of a simple graph with controls to * demo the zoomand hyperbolic features. * // w w w . ja va 2 s . c om */ public RadialTreeLensDemo() { // create a simple graph for the demo // create a simple graph for the demo graph = new DelegateForest<String, Integer>(); createTree(); layout = new TreeLayout<String, Integer>(graph); radialLayout = new RadialTreeLayout<String, Integer>(graph); radialLayout.setSize(new Dimension(600, 600)); Dimension preferredSize = new Dimension(600, 600); final VisualizationModel<String, Integer> visualizationModel = new DefaultVisualizationModel<String, Integer>( radialLayout, preferredSize); vv = new VisualizationViewer<String, Integer>(visualizationModel, preferredSize); PickedState<String> ps = vv.getPickedVertexState(); PickedState<Integer> pes = vv.getPickedEdgeState(); vv.getRenderContext().setVertexFillPaintTransformer( new PickableVertexPaintTransformer<String>(ps, Color.red, Color.yellow)); vv.getRenderContext().setEdgeDrawPaintTransformer( new PickableEdgePaintTransformer<Integer>(pes, Color.black, Color.cyan)); vv.setBackground(Color.white); vv.getRenderContext().setVertexLabelTransformer(new ToStringLabeller<String>()); vv.getRenderContext().setEdgeShapeTransformer(new EdgeShape.Line()); // add a listener for ToolTips vv.setVertexToolTipTransformer(new ToStringLabeller<String>()); Container content = getContentPane(); GraphZoomScrollPane gzsp = new GraphZoomScrollPane(vv); content.add(gzsp); /** * the regular graph mouse for the normal view */ final DefaultModalGraphMouse graphMouse = new DefaultModalGraphMouse(); vv.setGraphMouse(graphMouse); vv.addKeyListener(graphMouse.getModeKeyListener()); rings = new Rings(); vv.addPreRenderPaintable(rings); hyperbolicViewSupport = new ViewLensSupport<String, Integer>(vv, new HyperbolicShapeTransformer(vv, vv.getRenderContext().getMultiLayerTransformer().getTransformer(Layer.VIEW)), new ModalLensGraphMouse()); final ScalingControl scaler = new CrossoverScalingControl(); JButton plus = new JButton("+"); plus.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { scaler.scale(vv, 1.1f, vv.getCenter()); } }); JButton minus = new JButton("-"); minus.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { scaler.scale(vv, 1 / 1.1f, vv.getCenter()); } }); final JRadioButton hyperView = new JRadioButton("Hyperbolic View"); hyperView.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { hyperbolicViewSupport.activate(e.getStateChange() == ItemEvent.SELECTED); } }); graphMouse.addItemListener(hyperbolicViewSupport.getGraphMouse().getModeListener()); JMenuBar menubar = new JMenuBar(); menubar.add(graphMouse.getModeMenu()); gzsp.setCorner(menubar); JPanel controls = new JPanel(); JPanel zoomControls = new JPanel(new GridLayout(2, 1)); zoomControls.setBorder(BorderFactory.createTitledBorder("Zoom")); JPanel hyperControls = new JPanel(new GridLayout(3, 2)); hyperControls.setBorder(BorderFactory.createTitledBorder("Examiner Lens")); zoomControls.add(plus); zoomControls.add(minus); JPanel modeControls = new JPanel(new BorderLayout()); modeControls.setBorder(BorderFactory.createTitledBorder("Mouse Mode")); modeControls.add(graphMouse.getModeComboBox()); hyperControls.add(hyperView); controls.add(zoomControls); controls.add(hyperControls); controls.add(modeControls); content.add(controls, BorderLayout.SOUTH); }
From source file:net.sf.dynamicreports.test.jasper.chart.CandlestickChartTest.java
@Override public void test() { super.test(); numberOfPagesTest(1);//from ww w. j av a 2 s. c o m JFreeChart chart = getChart("summary.chart1", 0); XYItemRenderer renderer = chart.getXYPlot().getRenderer(); Assert.assertEquals("renderer", CandlestickRenderer.class, renderer.getClass()); Assert.assertEquals("show volume", false, ((CandlestickRenderer) renderer).getDrawVolume()); highLowChartDataTest(chart, 0, new Object[][] { { "serie", date1, 50d, 35d, 40d, 47d, 70d }, { "serie", date2, 55d, 40d, 50d, 45d, 120d }, { "serie", date3, 48d, 41d, 42d, 47d, 90d } }); chart = getChart("summary.chart2", 0); Axis axis = chart.getXYPlot().getDomainAxis(); Assert.assertEquals("category label", "time", axis.getLabel()); Assert.assertEquals("category label color", Color.BLUE, axis.getLabelPaint()); Assert.assertEquals("category label font", new Font("Arial", Font.BOLD, 10), axis.getLabelFont()); Assert.assertEquals("tick label color", Color.CYAN, axis.getTickLabelPaint()); Assert.assertEquals("tick label font", new Font("Arial", Font.ITALIC, 10), axis.getTickLabelFont()); Assert.assertEquals("line color", Color.LIGHT_GRAY, axis.getAxisLinePaint()); Assert.assertTrue("vertical tick labels", ((ValueAxis) axis).isVerticalTickLabels()); chart = getChart("summary.chart3", 0); axis = chart.getXYPlot().getRangeAxis(); Assert.assertEquals("value label", "value", axis.getLabel()); Assert.assertEquals("value label color", Color.BLUE, axis.getLabelPaint()); Assert.assertEquals("value label font", new Font("Arial", Font.BOLD, 10), axis.getLabelFont()); Assert.assertEquals("tick label color", Color.CYAN, axis.getTickLabelPaint()); Assert.assertEquals("tick label font", new Font("Arial", Font.ITALIC, 10), axis.getTickLabelFont()); Assert.assertEquals("tick label mask", "10.00", ((NumberAxis) axis).getNumberFormatOverride().format(10)); //Assert.assertEquals("line color", Color.LIGHT_GRAY, axis.getAxisLinePaint()); Assert.assertEquals("range min value", 1d, ((ValueAxis) axis).getLowerBound()); Assert.assertEquals("range max value", 15d, ((ValueAxis) axis).getUpperBound()); Assert.assertTrue("vertical tick labels", ((ValueAxis) axis).isVerticalTickLabels()); }
From source file:org.osjava.reportrunner_plugins.renderers.jfreechart.creators.TexturedBarRenderer.java
public java.awt.Paint getSeriesPaint(int row) { BufferedImage bufferedImage = new BufferedImage(5, 5, BufferedImage.TYPE_INT_RGB); Graphics2D big = bufferedImage.createGraphics(); TexturePaint texture = null;/* ww w . j a va 2 s .com*/ int rowNum = row + 1; int patNum = 13; int formula = rowNum - ((rowNum / patNum) * patNum); if (formula == 0) { big.setColor(Color.orange); big.fillRect(0, 0, 5, 5); big.fillRect(1, 0, 5, 5); Rectangle r = new Rectangle(0, 0, 5, 5); texture = new TexturePaint(bufferedImage, r); } else if (formula == 1) { big.setColor(Color.red); big.fillRect(0, 0, 5, 5); big.fillRect(1, 0, 5, 5); Rectangle r = new Rectangle(0, 0, 5, 5); texture = new TexturePaint(bufferedImage, r); } else if (formula == 2) { Color color = Color.blue; big.setColor(Color.white); big.fillRect(0, 0, 5, 5); big.setColor(color); big.fillRect(0, 1, 5, 5); Rectangle r = new Rectangle(0, 0, 5, 5); texture = new TexturePaint(bufferedImage, r); } else if (formula == 3) { Color color = Color.yellow; big.setColor(Color.orange); big.fillRect(0, 0, 5, 5); big.setColor(color); big.fillRect(1, 1, 4, 4); Rectangle r = new Rectangle(0, 0, 5, 5); texture = new TexturePaint(bufferedImage, r); } else if (formula == 4) { big.setColor(Color.green); big.fillRect(0, 0, 5, 5); big.fillRect(1, 0, 5, 5); Rectangle r = new Rectangle(0, 0, 5, 5); texture = new TexturePaint(bufferedImage, r); } else if (formula == 5) { big.setColor(Color.magenta); big.fillRect(0, 0, 5, 5); big.setColor(Color.pink); big.fillRect(0, 0, 4, 4); Rectangle r = new Rectangle(0, 0, 5, 5); texture = new TexturePaint(bufferedImage, r); } else if (formula == 6) { float[] x = { .5f, 1.5f, 2.0f, 2.5f, 3.0f, 3.5f, 4.0f, 4.5f, 5.0f }; float[] y = { .5f, 1.5f, 2.0f, 2.5f, 3.0f, 3.5f, 4.0f, 4.5f, 5.0f }; GeneralPath path = new GeneralPath(); path.moveTo(x[0], y[0]); for (int j = 1; j < x.length; j++) { path.lineTo(x[j], y[j]); } big.setColor(new Color(226, 199, 252)); big.fillRect(0, 0, 5, 5); big.setColor(Color.blue); big.setStroke(new BasicStroke(1.0f)); big.draw(path); Rectangle r = new Rectangle(0, 0, 5, 5); texture = new TexturePaint(bufferedImage, r); } else if (formula == 7) { big.setColor(Color.lightGray); big.fillRect(0, 0, 5, 5); big.setColor(Color.red); big.fillRect(1, 0, 5, 5); Rectangle r = new Rectangle(0, 0, 5, 5); texture = new TexturePaint(bufferedImage, r); } else if (formula == 8) { float[] x = { .5f, 1.5f, 2.0f, 2.5f, 3.0f, 3.5f, 4.0f, 4.5f, 5.0f }; float[] y = { .5f, 1.5f, 2.0f, 2.5f, 3.0f, 3.5f, 4.0f, 4.5f, 5.0f }; GeneralPath path = new GeneralPath(); path.moveTo(x[0], y[0]); for (int j = 1; j < x.length; j++) { path.lineTo(x[j], y[j]); } big.setColor(Color.blue); big.fillRect(0, 0, 5, 5); big.setColor(Color.cyan); big.setStroke(new BasicStroke(2.0f)); big.draw(path); Rectangle r = new Rectangle(0, 0, 5, 5); texture = new TexturePaint(bufferedImage, r); } else if (formula == 9) { Color color = new Color(0xBBBBDD); big.setColor(color); big.fillRect(0, 0, 5, 5); big.setColor(new Color(199, 201, 230)); big.fillRect(1, 0, 5, 5); Rectangle r = new Rectangle(0, 0, 5, 5); texture = new TexturePaint(bufferedImage, r); } else if (formula == 10) { float[] x = { 1, 2, 3, 4, 5 }; float[] y = { 1, 2, 3, 4, 5 }; GeneralPath path = new GeneralPath(); path.moveTo(x[0], y[1]); path.lineTo(x[1], y[0]); path.moveTo(x[0], y[2]); path.lineTo(x[2], y[0]); path.moveTo(x[0], y[3]); path.lineTo(x[3], y[0]); path.moveTo(x[0], y[4]); path.lineTo(x[4], y[0]); big.setColor(Color.red); big.fillRect(0, 0, 5, 5); big.setColor(new Color(242, 242, 193)); big.setStroke(new BasicStroke(3.0f)); big.draw(path); Rectangle r = new Rectangle(0, 0, 5, 5); texture = new TexturePaint(bufferedImage, r); } else if (formula == 11) { big.setColor(new Color(252, 169, 171)); big.fillOval(0, 0, 5, 6); big.setColor(new Color(252, 230, 230)); big.fillOval(0, 0, 3, 3); Rectangle r = new Rectangle(0, 0, 5, 5); texture = new TexturePaint(bufferedImage, r); } else if (formula == 12) { big.setColor(Color.green); big.fillRect(0, 0, 5, 5); big.setColor(new Color(20, 178, 38)); big.fillRect(2, 2, 5, 5); Rectangle r = new Rectangle(0, 0, 5, 5); texture = new TexturePaint(bufferedImage, r); } return texture; }
From source file:edu.uci.ics.jung.samples.RadialTreeLensDemo.java
/** * create an instance of a simple graph with controls to * demo the zoomand hyperbolic features. * //from w w w . j av a2 s.c o m */ @SuppressWarnings({ "unchecked", "rawtypes" }) public RadialTreeLensDemo() { // create a simple graph for the demo // create a simple graph for the demo graph = new DelegateForest<String, Integer>(); createTree(); layout = new TreeLayout<String, Integer>(graph); radialLayout = new RadialTreeLayout<String, Integer>(graph); radialLayout.setSize(new Dimension(600, 600)); Dimension preferredSize = new Dimension(600, 600); final VisualizationModel<String, Integer> visualizationModel = new DefaultVisualizationModel<String, Integer>( radialLayout, preferredSize); vv = new VisualizationViewer<String, Integer>(visualizationModel, preferredSize); PickedState<String> ps = vv.getPickedVertexState(); PickedState<Integer> pes = vv.getPickedEdgeState(); vv.getRenderContext().setVertexFillPaintTransformer( new PickableVertexPaintTransformer<String>(ps, Color.red, Color.yellow)); vv.getRenderContext().setEdgeDrawPaintTransformer( new PickableEdgePaintTransformer<Integer>(pes, Color.black, Color.cyan)); vv.setBackground(Color.white); vv.getRenderContext().setVertexLabelTransformer(new ToStringLabeller<String>()); vv.getRenderContext().setEdgeShapeTransformer(new EdgeShape.Line()); // add a listener for ToolTips vv.setVertexToolTipTransformer(new ToStringLabeller<String>()); Container content = getContentPane(); GraphZoomScrollPane gzsp = new GraphZoomScrollPane(vv); content.add(gzsp); /** * the regular graph mouse for the normal view */ final DefaultModalGraphMouse graphMouse = new DefaultModalGraphMouse(); vv.setGraphMouse(graphMouse); vv.addKeyListener(graphMouse.getModeKeyListener()); rings = new Rings(); vv.addPreRenderPaintable(rings); hyperbolicViewSupport = new ViewLensSupport<String, Integer>(vv, new HyperbolicShapeTransformer(vv, vv.getRenderContext().getMultiLayerTransformer().getTransformer(Layer.VIEW)), new ModalLensGraphMouse()); final ScalingControl scaler = new CrossoverScalingControl(); JButton plus = new JButton("+"); plus.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { scaler.scale(vv, 1.1f, vv.getCenter()); } }); JButton minus = new JButton("-"); minus.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { scaler.scale(vv, 1 / 1.1f, vv.getCenter()); } }); final JRadioButton hyperView = new JRadioButton("Hyperbolic View"); hyperView.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { hyperbolicViewSupport.activate(e.getStateChange() == ItemEvent.SELECTED); } }); graphMouse.addItemListener(hyperbolicViewSupport.getGraphMouse().getModeListener()); JMenuBar menubar = new JMenuBar(); menubar.add(graphMouse.getModeMenu()); gzsp.setCorner(menubar); JPanel controls = new JPanel(); JPanel zoomControls = new JPanel(new GridLayout(2, 1)); zoomControls.setBorder(BorderFactory.createTitledBorder("Zoom")); JPanel hyperControls = new JPanel(new GridLayout(3, 2)); hyperControls.setBorder(BorderFactory.createTitledBorder("Examiner Lens")); zoomControls.add(plus); zoomControls.add(minus); JPanel modeControls = new JPanel(new BorderLayout()); modeControls.setBorder(BorderFactory.createTitledBorder("Mouse Mode")); modeControls.add(graphMouse.getModeComboBox()); hyperControls.add(hyperView); controls.add(zoomControls); controls.add(hyperControls); controls.add(modeControls); content.add(controls, BorderLayout.SOUTH); }