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:joshua.ui.hypergraph_visualizer.HyperGraphViewer.java
private Transformer<Vertex, Paint> vertexPainter() { return new Transformer<Vertex, Paint>() { private Color[] colors = { Color.blue, Color.red, Color.yellow, Color.green, Color.cyan }; public Paint transform(Vertex v) { return colors[v.getColor() % colors.length]; }//from www . ja va 2 s . c om }; }
From source file:org.deeplearning4j.ui.TestRendering.java
@Ignore @Test//from w ww. j a va2 s . co m public void test() throws Exception { List<Component> list = new ArrayList<>(); //Common style for all of the charts StyleChart s = new StyleChart.Builder().width(640, LengthUnit.Px).height(480, LengthUnit.Px) .margin(LengthUnit.Px, 100, 40, 40, 20).strokeWidth(2).pointSize(4) .seriesColors(Color.GREEN, Color.MAGENTA).titleStyle(new StyleText.Builder().font("courier") .fontSize(16).underline(true).color(Color.GRAY).build()) .build(); //Line chart with vertical grid Component c1 = new ChartLine.Builder("Line Chart!", s) .addSeries("series0", new double[] { 0, 1, 2, 3 }, new double[] { 0, 2, 1, 4 }) .addSeries("series1", new double[] { 0, 1, 2, 3 }, new double[] { 0, 1, 0.5, 2.5 }) .setGridWidth(1.0, null) //Vertical grid lines, no horizontal grid .build(); list.add(c1); //Scatter chart Component c2 = new ChartScatter.Builder("Scatter!", s) .addSeries("series0", new double[] { 0, 1, 2, 3 }, new double[] { 0, 2, 1, 4 }).showLegend(true) .setGridWidth(0, 0).build(); list.add(c2); //Histogram with variable sized bins Component c3 = new ChartHistogram.Builder("Histogram!", s).addBin(-1, -0.5, 0.2).addBin(-0.5, 0, 0.5) .addBin(0, 1, 2.5).addBin(1, 2, 0.5).build(); list.add(c3); //Stacked area chart Component c4 = new ChartStackedArea.Builder("Area Chart!", s).setXValues(new double[] { 0, 1, 2, 3, 4, 5 }) .addSeries("series0", new double[] { 0, 1, 0, 2, 0, 1 }) .addSeries("series1", new double[] { 2, 1, 2, 0.5, 2, 1 }).build(); list.add(c4); //Table StyleTable ts = new StyleTable.Builder().backgroundColor(Color.LIGHT_GRAY).headerColor(Color.ORANGE) .borderWidth(1).columnWidths(LengthUnit.Percent, 20, 40, 40).width(500, LengthUnit.Px) .height(200, LengthUnit.Px).build(); Component c5 = new ComponentTable.Builder(ts).header("H1", "H2", "H3").content( new String[][] { { "row0col0", "row0col1", "row0col2" }, { "row1col0", "row1col1", "row1col2" } }) .build(); list.add(c5); //Accordion decorator, with the same chart StyleAccordion ac = new StyleAccordion.Builder().height(480, LengthUnit.Px).width(640, LengthUnit.Px) .build(); Component c6 = new DecoratorAccordion.Builder(ac).title("Accordion - Collapsed By Default!") .setDefaultCollapsed(true).addComponents(c5).build(); list.add(c6); //Text with styling Component c7 = new ComponentText.Builder("Here's some blue text in a green div!", new StyleText.Builder().font("courier").fontSize(30).underline(true).color(Color.BLUE).build()) .build(); //Div, with a chart inside Style divStyle = new StyleDiv.Builder().width(30, LengthUnit.Percent).height(200, LengthUnit.Px) .backgroundColor(Color.GREEN).floatValue(StyleDiv.FloatValue.right).build(); Component c8 = new ComponentDiv(divStyle, c7, new ComponentText("(Also: it's float right, 30% width, 200 px high )", null)); list.add(c8); //Timeline chart: List<ChartTimeline.TimelineEntry> entries = new ArrayList<>(); for (int i = 0; i < 10; i++) { entries.add(new ChartTimeline.TimelineEntry("e0-" + i, 10 * i, 10 * i + 5, Color.BLUE)); } List<ChartTimeline.TimelineEntry> entries2 = new ArrayList<>(); for (int i = 0; i < 10; i++) { entries2.add(new ChartTimeline.TimelineEntry("e1-" + i, (int) (5 * i + 0.2 * i * i), (int) (5 * i + 0.2 * i * i) + 3, Color.ORANGE)); } List<ChartTimeline.TimelineEntry> entries3 = new ArrayList<>(); for (int i = 0; i < 10; i++) { entries3.add(new ChartTimeline.TimelineEntry("e2-" + i, (int) (2 * i + 0.6 * i * i + 3), (int) (2 * i + 0.6 * i * i + 3) + 2 * i + 1)); } Color[] c = new Color[] { Color.CYAN, Color.YELLOW, Color.GREEN, Color.PINK }; List<ChartTimeline.TimelineEntry> entries4 = new ArrayList<>(); Random r = new Random(12345); for (int i = 0; i < 10; i++) { entries4.add(new ChartTimeline.TimelineEntry("e3-" + i, (int) (2 * i + 0.6 * i * i + 3), (int) (2 * i + 0.6 * i * i + 3) + i + 1, c[r.nextInt(c.length)])); } Component c9 = new ChartTimeline.Builder("Title", s).addLane("Lane 0", entries).addLane("Lane 1", entries2) .addLane("Lane 2", entries3).addLane("Lane 3", entries4).build(); list.add(c9); //Generate HTML StringBuilder sb = new StringBuilder(); sb.append("<!DOCTYPE html>\n" + "<html lang=\"en\">\n" + "<head>\n" + " <meta charset=\"UTF-8\">\n" + " <title>Title</title>\n" + "</head>\n" + "<body>\n" + "\n" + " <div id=\"maindiv\">\n" + "\n" + " </div>\n" + "\n" + "\n" + " <script src=\"//code.jquery.com/jquery-1.10.2.js\"></script>\n" + " <script src=\"https://code.jquery.com/ui/1.11.4/jquery-ui.min.js\"></script>\n" + " <link rel=\"stylesheet\" href=\"//code.jquery.com/ui/1.11.4/themes/smoothness/jquery-ui.css\">\n" + " <script src=\"https://cdnjs.cloudflare.com/ajax/libs/d3/3.5.5/d3.min.js\"></script>\n" + " <script src=\"src/main/resources/assets/dl4j-ui.js\"></script>\n" + "\n" + " <script>\n"); ObjectMapper om = new ObjectMapper(); for (int i = 0; i < list.size(); i++) { Component component = list.get(i); sb.append(" ").append("var str").append(i).append(" = '") .append(om.writeValueAsString(component).replaceAll("'", "\\\\'")).append("';\n"); sb.append(" ").append("var obj").append(i).append(" = Component.getComponent(str").append(i) .append(");\n"); sb.append(" ").append("obj").append(i).append(".render($('#maindiv'));\n"); sb.append("\n\n"); } sb.append(" </script>\n" + "\n" + "</body>\n" + "</html>"); FileUtils.writeStringToFile(new File("TestRendering.html"), sb.toString()); }
From source file:org.pau.assetmanager.viewmodel.chart.PrepareChart.java
public static void preparePropertiesVsOwnAllPropertiesJFreeChart(JFreeChart jfchart, CategoryDataset categoryModel) { CategoryPlot categoryPlot = ((CategoryPlot) jfchart.getPlot()); categoryPlot.getRangeAxis().resizeRange(1.2); categoryPlot.setBackgroundPaint(Color.WHITE); categoryPlot.setDomainGridlinePaint(Color.WHITE); categoryPlot.setRangeMinorGridlinePaint(Color.WHITE); categoryPlot.setRangeGridlinePaint(Color.BLACK); BarRenderer renderer = (BarRenderer) categoryPlot.getRenderer(); renderer.setBaseItemLabelGenerator(new StandardCategoryItemLabelGenerator()); renderer.setBaseItemLabelsVisible(true); renderer.setBaseItemLabelFont(new Font("Serif", Font.PLAIN, 10)); renderer.setItemLabelAnchorOffset(15); renderer.setSeriesStroke(0, new BasicStroke(1)); renderer.setSeriesStroke(1, new BasicStroke(1)); renderer.setSeriesStroke(2, new BasicStroke(1)); renderer.setSeriesStroke(3, new BasicStroke(1)); renderer.setSeriesStroke(4, new BasicStroke(1)); renderer.setSeriesStroke(5, new BasicStroke(1)); renderer.setSeriesPaint(0, new Color(0x77, 0x77, 0xFF)); renderer.setSeriesPaint(1, new Color(0xCC, 0xCC, 0xFF)); renderer.setSeriesPaint(2, new Color(0x00, 0x00, 0xFF)); renderer.setSeriesPaint(3, new Color(0xFF, 0x77, 0x77)); renderer.setSeriesPaint(4, new Color(0xFF, 0xCC, 0xCC)); renderer.setSeriesPaint(5, new Color(0xFF, 0x00, 0x00)); for (int i = 0; i < categoryModel.getColumnKeys().size(); i++) { String label = (String) categoryModel.getColumnKey(i); CategoryMarker marker = new CategoryMarker(label); marker.setLabel(""); marker.setPaint(Color.cyan); marker.setOutlinePaint(Color.cyan); marker.setAlpha(0.1f);/*from w w w . j a v a2s. c o m*/ marker.setLabelAnchor(RectangleAnchor.TOP); marker.setLabelTextAnchor(TextAnchor.TOP_CENTER); marker.setLabelOffsetType(LengthAdjustmentType.CONTRACT); categoryPlot.addDomainMarker(marker, Layer.BACKGROUND); } renderer.setDrawBarOutline(false); renderer.setShadowVisible(false); renderer.setItemMargin(.1); renderer.setBarPainter(new StandardBarPainter()); renderer.setBasePositiveItemLabelPosition( new ItemLabelPosition(ItemLabelAnchor.OUTSIDE12, TextAnchor.TOP_RIGHT)); renderer.setBaseNegativeItemLabelPosition( new ItemLabelPosition(ItemLabelAnchor.OUTSIDE6, TextAnchor.BOTTOM_RIGHT)); }
From source file:org.yawlfoundation.yawl.procletService.editor.pconns.VertexDemo.java
public VertexDemo() { // create a simple graph for the demo graph = new DirectedSparseGraph<Number, Number>(); createGraph(VERTEX_COUNT);//from www . java2 s .c o m // a Map for the labels Map<Number, String> map = new HashMap<Number, String>(); for (int i = 0; i < VERTEX_COUNT; i++) { map.put(i, iconNames[i % iconNames.length]); } // a Map for the Icons Map<Number, Icon> iconMap = new HashMap<Number, Icon>(); for (int i = 0; i < VERTEX_COUNT; i++) { String name = "/images/topic" + iconNames[i] + ".gif"; try { Icon icon = new LayeredIcon(new ImageIcon(VertexDemo.class.getResource(name)).getImage()); iconMap.put(i, icon); } catch (Exception ex) { System.err.println("You need slashdoticons.jar in your classpath to see the image " + name); } } FRLayout<Number, Number> layout = new FRLayout<Number, Number>(graph); layout.setMaxIterations(100); layout.setInitializer(new RandomLocationTransformer<Number>(new Dimension(400, 400), 0)); vv = new VisualizationViewer<Number, Number>(layout, new Dimension(400, 400)); // This demo uses a special renderer to turn outlines on and off. // you do not need to do this in a real application. // Instead, just let vv use the Renderer it already has vv.getRenderer().setVertexRenderer(new DemoRenderer<Number, Number>()); Transformer<Number, Paint> vpf = new PickableVertexPaintTransformer<Number>(vv.getPickedVertexState(), Color.white, Color.yellow); vv.getRenderContext().setVertexFillPaintTransformer(vpf); vv.getRenderContext().setEdgeDrawPaintTransformer( new PickableEdgePaintTransformer<Number>(vv.getPickedEdgeState(), Color.black, Color.cyan)); vv.setBackground(Color.white); final Transformer<Number, String> vertexStringerImpl = new VertexStringerImpl<Number, String>(map); vv.getRenderContext().setVertexLabelTransformer(vertexStringerImpl); vv.getRenderContext().setVertexLabelRenderer(new DefaultVertexLabelRenderer(Color.cyan)); vv.getRenderContext().setEdgeLabelRenderer(new DefaultEdgeLabelRenderer(Color.cyan)); // vv.getRenderContext().setEdgeLabelTransformer(new Transformer<Number,String>() { // URL url = getClass().getResource("/images/lightning-s.gif"); // public String transform(Number input) { // // return "<html><img src="+url+" height=10 width=21>"+input.toString(); // }}); // For this demo only, I use a special class that lets me turn various // features on and off. For a real application, use VertexIconShapeTransformer instead. final DemoVertexIconShapeTransformer<Number> vertexIconShapeTransformer = new DemoVertexIconShapeTransformer<Number>( new EllipseVertexShapeTransformer<Number>()); final DemoVertexIconTransformer<Number> vertexIconTransformer = new DemoVertexIconTransformer<Number>(); vertexIconShapeTransformer.setIconMap(iconMap); vertexIconTransformer.setIconMap(iconMap); vv.getRenderContext().setVertexShapeTransformer(vertexIconShapeTransformer); vv.getRenderContext().setVertexIconTransformer(vertexIconTransformer); // un-comment for RStar Tree visual testing //vv.addPostRenderPaintable(new BoundingRectanglePaintable(vv.getRenderContext(), vv.getGraphLayout())); // Get the pickedState and add a listener that will decorate the // Vertex images with a checkmark icon when they are picked PickedState<Number> ps = vv.getPickedVertexState(); ps.addItemListener(new PickWithIconListener<Number>(vertexIconTransformer)); vv.addPostRenderPaintable(new VisualizationViewer.Paintable() { int x; int y; Font font; FontMetrics metrics; int swidth; int sheight; String str = "Thank You, slashdot.org, for the images!"; public void paint(Graphics g) { Dimension d = vv.getSize(); if (font == null) { font = new Font(g.getFont().getName(), Font.BOLD, 20); metrics = g.getFontMetrics(font); swidth = metrics.stringWidth(str); sheight = metrics.getMaxAscent() + metrics.getMaxDescent(); x = (d.width - swidth) / 2; y = (int) (d.height - sheight * 1.5); } g.setFont(font); Color oldColor = g.getColor(); g.setColor(Color.lightGray); g.drawString(str, x, y); g.setColor(oldColor); } public boolean useTransform() { return false; } }); // add a listener for ToolTips vv.setVertexToolTipTransformer(new ToStringLabeller<Number>()); Container content = getContentPane(); final GraphZoomScrollPane panel = new GraphZoomScrollPane(vv); content.add(panel); final DefaultModalGraphMouse<Number, Number> graphMouse = new DefaultModalGraphMouse<Number, Number>(); vv.setGraphMouse(graphMouse); vv.addKeyListener(graphMouse.getModeKeyListener()); 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()); } }); JCheckBox shape = new JCheckBox("Shape"); shape.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { vertexIconShapeTransformer.setShapeImages(e.getStateChange() == ItemEvent.SELECTED); vv.repaint(); } }); shape.setSelected(true); JCheckBox fill = new JCheckBox("Fill"); fill.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { vertexIconTransformer.setFillImages(e.getStateChange() == ItemEvent.SELECTED); vv.repaint(); } }); fill.setSelected(true); JCheckBox drawOutlines = new JCheckBox("Outline"); drawOutlines.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { vertexIconTransformer.setOutlineImages(e.getStateChange() == ItemEvent.SELECTED); vv.repaint(); } }); JComboBox modeBox = graphMouse.getModeComboBox(); JPanel modePanel = new JPanel(); modePanel.setBorder(BorderFactory.createTitledBorder("Mouse Mode")); modePanel.add(modeBox); JPanel scaleGrid = new JPanel(new GridLayout(1, 0)); scaleGrid.setBorder(BorderFactory.createTitledBorder("Zoom")); JPanel labelFeatures = new JPanel(new GridLayout(1, 0)); labelFeatures.setBorder(BorderFactory.createTitledBorder("Image Effects")); JPanel controls = new JPanel(); scaleGrid.add(plus); scaleGrid.add(minus); controls.add(scaleGrid); labelFeatures.add(shape); labelFeatures.add(fill); labelFeatures.add(drawOutlines); controls.add(labelFeatures); controls.add(modePanel); content.add(controls, BorderLayout.SOUTH); }
From source file:com.google.code.facebook.graph.sna.applet.VertexImageShaperDemo.java
public VertexImageShaperDemo() { // create a simple graph for the demo graph = new DirectedSparseGraph<Number, Number>(); createGraph(VERTEX_COUNT);/*from w ww . j a v a 2s .c o m*/ // a Map for the labels Map<Number, String> map = new HashMap<Number, String>(); for (int i = 0; i < VERTEX_COUNT; i++) { map.put(i, iconNames[i % iconNames.length]); } // a Map for the Icons Map<Number, Icon> iconMap = new HashMap<Number, Icon>(); for (int i = 0; i < VERTEX_COUNT; i++) { String name = "/images/topic" + iconNames[i] + ".gif"; try { Icon icon = new LayeredIcon( new ImageIcon(VertexImageShaperDemo.class.getResource(name)).getImage()); iconMap.put(i, icon); } catch (Exception ex) { System.err.println("You need slashdoticons.jar in your classpath to see the image " + name); } } FRLayout<Number, Number> layout = new FRLayout<Number, Number>(graph); layout.setMaxIterations(100); layout.setInitializer(new RandomLocationTransformer<Number>(new Dimension(400, 400), 0)); vv = new VisualizationViewer<Number, Number>(layout, new Dimension(400, 400)); // This demo uses a special renderer to turn outlines on and off. // you do not need to do this in a real application. // Instead, just let vv use the Renderer it already has vv.getRenderer().setVertexRenderer(new DemoRenderer<Number, Number>()); Transformer<Number, Paint> vpf = new PickableVertexPaintTransformer<Number>(vv.getPickedVertexState(), Color.white, Color.yellow); vv.getRenderContext().setVertexFillPaintTransformer(vpf); vv.getRenderContext().setEdgeDrawPaintTransformer( new PickableEdgePaintTransformer<Number>(vv.getPickedEdgeState(), Color.black, Color.cyan)); vv.setBackground(Color.white); final Transformer<Number, String> vertexStringerImpl = new VertexStringerImpl<Number, String>(map); vv.getRenderContext().setVertexLabelTransformer(vertexStringerImpl); vv.getRenderContext().setVertexLabelRenderer(new DefaultVertexLabelRenderer(Color.cyan)); vv.getRenderContext().setEdgeLabelRenderer(new DefaultEdgeLabelRenderer(Color.cyan)); // vv.getRenderContext().setEdgeLabelTransformer(new Transformer<Number,String>() { // URL url = getClass().getResource("/images/lightning-s.gif"); // public String transform(Number input) { // // return "<html><img src="+url+" height=10 width=21>"+input.toString(); // }}); // For this demo only, I use a special class that lets me turn various // features on and off. For a real application, use VertexIconShapeTransformer instead. final DemoVertexIconShapeTransformer<Number> vertexIconShapeTransformer = new DemoVertexIconShapeTransformer<Number>( new EllipseVertexShapeTransformer<Number>()); final DemoVertexIconTransformer<Number> vertexIconTransformer = new DemoVertexIconTransformer<Number>(); vertexIconShapeTransformer.setIconMap(iconMap); vertexIconTransformer.setIconMap(iconMap); vv.getRenderContext().setVertexShapeTransformer(vertexIconShapeTransformer); vv.getRenderContext().setVertexIconTransformer(vertexIconTransformer); // un-comment for RStar Tree visual testing //vv.addPostRenderPaintable(new BoundingRectanglePaintable(vv.getRenderContext(), vv.getGraphLayout())); // Get the pickedState and add a listener that will decorate the // Vertex images with a checkmark icon when they are picked PickedState<Number> ps = vv.getPickedVertexState(); ps.addItemListener(new PickWithIconListener<Number>(vertexIconTransformer)); vv.addPostRenderPaintable(new VisualizationViewer.Paintable() { int x; int y; Font font; FontMetrics metrics; int swidth; int sheight; String str = "Thank You, slashdot.org, for the images!"; public void paint(Graphics g) { Dimension d = vv.getSize(); if (font == null) { font = new Font(g.getFont().getName(), Font.BOLD, 20); metrics = g.getFontMetrics(font); swidth = metrics.stringWidth(str); sheight = metrics.getMaxAscent() + metrics.getMaxDescent(); x = (d.width - swidth) / 2; y = (int) (d.height - sheight * 1.5); } g.setFont(font); Color oldColor = g.getColor(); g.setColor(Color.lightGray); g.drawString(str, x, y); g.setColor(oldColor); } public boolean useTransform() { return false; } }); // add a listener for ToolTips vv.setVertexToolTipTransformer(new ToStringLabeller<Number>()); Container content = getContentPane(); final GraphZoomScrollPane panel = new GraphZoomScrollPane(vv); content.add(panel); final DefaultModalGraphMouse<Number, Number> graphMouse = new DefaultModalGraphMouse<Number, Number>(); vv.setGraphMouse(graphMouse); vv.addKeyListener(graphMouse.getModeKeyListener()); 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()); } }); JCheckBox shape = new JCheckBox("Shape"); shape.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { vertexIconShapeTransformer.setShapeImages(e.getStateChange() == ItemEvent.SELECTED); vv.repaint(); } }); shape.setSelected(true); JCheckBox fill = new JCheckBox("Fill"); fill.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { vertexIconTransformer.setFillImages(e.getStateChange() == ItemEvent.SELECTED); vv.repaint(); } }); fill.setSelected(true); JCheckBox drawOutlines = new JCheckBox("Outline"); drawOutlines.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { vertexIconTransformer.setOutlineImages(e.getStateChange() == ItemEvent.SELECTED); vv.repaint(); } }); JComboBox modeBox = graphMouse.getModeComboBox(); JPanel modePanel = new JPanel(); modePanel.setBorder(BorderFactory.createTitledBorder("Mouse Mode")); modePanel.add(modeBox); JPanel scaleGrid = new JPanel(new GridLayout(1, 0)); scaleGrid.setBorder(BorderFactory.createTitledBorder("Zoom")); JPanel labelFeatures = new JPanel(new GridLayout(1, 0)); labelFeatures.setBorder(BorderFactory.createTitledBorder("Image Effects")); JPanel controls = new JPanel(); scaleGrid.add(plus); scaleGrid.add(minus); controls.add(scaleGrid); labelFeatures.add(shape); labelFeatures.add(fill); labelFeatures.add(drawOutlines); controls.add(labelFeatures); controls.add(modePanel); content.add(controls, BorderLayout.SOUTH); }
From source file:demo.VertexImageShaperDemo.java
public VertexImageShaperDemo() { // create a simple graph for the demo graph = new DirectedSparseGraph<Number, Number>(); createGraph(VERTEX_COUNT);/*w w w. j a v a 2s. c om*/ // a Map for the labels Map<Number, String> map = new HashMap<Number, String>(); for (int i = 0; i < VERTEX_COUNT; i++) { map.put(i, iconNames[i % iconNames.length]); } // a Map for the Icons Map<Number, Icon> iconMap = new HashMap<Number, Icon>(); for (int i = 0; i < VERTEX_COUNT; i++) { String name = "/images/topic" + iconNames[i] + ".gif"; try { Icon icon = new LayeredIcon( new ImageIcon(VertexImageShaperDemo.class.getResource(name)).getImage()); //iconMap.put(i, icon); iconMap.put(i, new ImageIcon("transferir.png")); } catch (Exception ex) { System.err.println("You need slashdoticons.jar in your classpath to see the image " + name); } } FRLayout<Number, Number> layout = new FRLayout<Number, Number>(graph); layout.setMaxIterations(100); layout.setInitializer(new RandomLocationTransformer<Number>(new Dimension(400, 400), 0)); vv = new VisualizationViewer<Number, Number>(layout, new Dimension(400, 400)); // This demo uses a special renderer to turn outlines on and off. // you do not need to do this in a real application. // Instead, just let vv use the Renderer it already has vv.getRenderer().setVertexRenderer(new DemoRenderer<Number, Number>()); Transformer<Number, Paint> vpf = new PickableVertexPaintTransformer<Number>(vv.getPickedVertexState(), Color.white, Color.yellow); vv.getRenderContext().setVertexFillPaintTransformer(vpf); vv.getRenderContext().setEdgeDrawPaintTransformer( new PickableEdgePaintTransformer<Number>(vv.getPickedEdgeState(), Color.black, Color.cyan)); vv.setBackground(Color.white); final Transformer<Number, String> vertexStringerImpl = new VertexStringerImpl<Number, String>(map); vv.getRenderContext().setVertexLabelTransformer(vertexStringerImpl); vv.getRenderContext().setVertexLabelRenderer(new DefaultVertexLabelRenderer(Color.cyan)); vv.getRenderContext().setEdgeLabelRenderer(new DefaultEdgeLabelRenderer(Color.cyan)); // vv.getRenderContext().setEdgeLabelTransformer(new Transformer<Number,String>() { // URL url = getClass().getResource("/images/lightning-s.gif"); // public String transform(Number input) { // // return "<html><img src="+url+" height=10 width=21>"+input.toString(); // }}); // For this demo only, I use a special class that lets me turn various // features on and off. For a real application, use VertexIconShapeTransformer instead. final DemoVertexIconShapeTransformer<Number> vertexIconShapeTransformer = new DemoVertexIconShapeTransformer<Number>( new EllipseVertexShapeTransformer<Number>()); final DemoVertexIconTransformer<Number> vertexIconTransformer = new DemoVertexIconTransformer<Number>(); vertexIconShapeTransformer.setIconMap(iconMap); vertexIconTransformer.setIconMap(iconMap); vv.getRenderContext().setVertexShapeTransformer(vertexIconShapeTransformer); vv.getRenderContext().setVertexIconTransformer(vertexIconTransformer); // un-comment for RStar Tree visual testing //vv.addPostRenderPaintable(new BoundingRectanglePaintable(vv.getRenderContext(), vv.getGraphLayout())); // Get the pickedState and add a listener that will decorate the // Vertex images with a checkmark icon when they are picked PickedState<Number> ps = vv.getPickedVertexState(); ps.addItemListener(new PickWithIconListener<Number>(vertexIconTransformer)); vv.addPostRenderPaintable(new VisualizationViewer.Paintable() { int x; int y; Font font; FontMetrics metrics; int swidth; int sheight; String str = "Thank You, slashdot.org, for the images!"; public void paint(Graphics g) { Dimension d = vv.getSize(); if (font == null) { font = new Font(g.getFont().getName(), Font.BOLD, 20); metrics = g.getFontMetrics(font); swidth = metrics.stringWidth(str); sheight = metrics.getMaxAscent() + metrics.getMaxDescent(); x = (d.width - swidth) / 2; y = (int) (d.height - sheight * 1.5); } g.setFont(font); Color oldColor = g.getColor(); g.setColor(Color.lightGray); g.drawString(str, x, y); g.setColor(oldColor); } public boolean useTransform() { return false; } }); // add a listener for ToolTips vv.setVertexToolTipTransformer(new ToStringLabeller<Number>()); Container content = getContentPane(); final GraphZoomScrollPane panel = new GraphZoomScrollPane(vv); content.add(panel); final DefaultModalGraphMouse<Number, Number> graphMouse = new DefaultModalGraphMouse<Number, Number>(); vv.setGraphMouse(graphMouse); vv.addKeyListener(graphMouse.getModeKeyListener()); 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()); } }); JCheckBox shape = new JCheckBox("Shape"); shape.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { vertexIconShapeTransformer.setShapeImages(e.getStateChange() == ItemEvent.SELECTED); vv.repaint(); } }); shape.setSelected(true); JCheckBox fill = new JCheckBox("Fill"); fill.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { vertexIconTransformer.setFillImages(e.getStateChange() == ItemEvent.SELECTED); vv.repaint(); } }); fill.setSelected(true); JCheckBox drawOutlines = new JCheckBox("Outline"); drawOutlines.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { vertexIconTransformer.setOutlineImages(e.getStateChange() == ItemEvent.SELECTED); vv.repaint(); } }); JComboBox modeBox = graphMouse.getModeComboBox(); JPanel modePanel = new JPanel(); modePanel.setBorder(BorderFactory.createTitledBorder("Mouse Mode")); modePanel.add(modeBox); JPanel scaleGrid = new JPanel(new GridLayout(1, 0)); scaleGrid.setBorder(BorderFactory.createTitledBorder("Zoom")); JPanel labelFeatures = new JPanel(new GridLayout(1, 0)); labelFeatures.setBorder(BorderFactory.createTitledBorder("Image Effects")); JPanel controls = new JPanel(); scaleGrid.add(plus); scaleGrid.add(minus); controls.add(scaleGrid); labelFeatures.add(shape); labelFeatures.add(fill); labelFeatures.add(drawOutlines); controls.add(labelFeatures); controls.add(modePanel); content.add(controls, BorderLayout.SOUTH); }
From source file:br.com.OCTur.view.GraficoController.java
private void produtosMaisAntigos() { DefaultCategoryDataset dcdDados = new DefaultCategoryDataset(); for (EntidadeGrafico<Produto> entidadeGrafico : produto) { if (entidadeGrafico.getValue() >= slMeta.getValue()) { dcdDados.addValue(entidadeGrafico.getValue(), "Dias/Acima do esperado", entidadeGrafico.toString()); } else {// w ww. j a va 2s . c om dcdDados.addValue(entidadeGrafico.getValue(), "Dias", entidadeGrafico.toString()); } } JFreeChart jFreeChart = ChartFactory.createBarChart(ControlTranducao.traduzirPalavra("PRODUTOSMAISANTIGOS"), "", "", dcdDados, PlotOrientation.VERTICAL, false, false, false); jFreeChart.getCategoryPlot().getRenderer().setBaseItemLabelGenerator( new StandardCategoryItemLabelGenerator("{0}", NumberFormat.getCurrencyInstance())); jFreeChart.getCategoryPlot() .addRangeMarker(new ValueMarker(slMeta.getValue(), Color.CYAN, new BasicStroke(1.0f))); ChartPanel chartPanel = new ChartPanel(jFreeChart); snProdutosMaisAntigos.setContent(chartPanel); }
From source file:com.bdb.weather.display.current.WindGauge.java
/** * Constructor./* ww w . java 2s . co m*/ */ public WindGauge() { this.setPrefSize(200.0, 200.0); lastHeading = 0.0; lastSpeed = 0.0; plot = new DialPlot(); for (int i = 0; i < WIND_DIR_ITEMS; i++) { datasets[i] = new DefaultValueDataset(); plot.setDataset(WIND_DIR_DATASET_INDEX_BASE + i, datasets[i]); } plot.setDataset(WIND_SPEED_DATASET_INDEX, speedDataset); plot.setDataset(WIND_GUST_DATASET_INDEX, gustDataset); plot.setDataset(MAX_WIND_SPEED_DATASET_INDEX, maxSpeedDataset); plot.setDataset(MAX_WIND_GUST_DATASET_INDEX, maxGustDataset); plot.addLayer( new DialBackground(new GradientPaint(0.0f, 0.0f, Color.LIGHT_GRAY, 100.0f, 0.0f, Color.blue))); StandardDialScale scale = new StandardDialScale(0.0, 360.0, 90.0, -360.0, 45.0, 1); scale.setTickLabelFont(scale.getTickLabelFont().deriveFont(14.0F).deriveFont(Font.PLAIN)); scale.setTickRadius(.9); scale.setTickLabelFormatter(new CompassHeadingFormat()); scale.setTickLabelOffset(0.06); scale.setMajorTickPaint(new Color(0, 0, 0, 0)); scale.setTickLabelPaint(Color.BLACK); scale.setMinorTickLength(scale.getMajorTickLength()); scale.setMinorTickStroke(scale.getMajorTickStroke()); plot.addScale(WIND_DIR_SCALE, scale); scale = new StandardDialScale(0.0, 50.0, 225.0, -270.0, 10.0, 9); scale.setTickLabelFont(scale.getTickLabelFont().deriveFont(14.0F).deriveFont(Font.PLAIN)); scale.setTickRadius(.4); scale.setTickLabelFormatter(new DecimalFormat("##")); scale.setTickLabelOffset(.15); scale.setTickLabelPaint(Color.BLACK); plot.addScale(WIND_SPEED_SCALE, scale); DialPointer.Pointer pointer; for (int i = 1; i < WIND_DIR_ITEMS; i++) { pointer = new WindDirPointer(.72, .2, WIND_DIR_DATASET_INDEX_BASE + i, false); pointer.setOutlinePaint(Color.RED); plot.addPointer(pointer); } plot.setDialFrame(new StandardDialFrame()); pointer = new WindDirPointer(.72, .2, WIND_DIR_DATASET_INDEX_BASE, true); Color fill = Color.CYAN; pointer.setFillPaint(fill); pointer.setOutlinePaint(Color.BLACK); plot.addPointer(pointer); DialCap cap = new DialCap(); plot.setCap(cap); DialPointer.Pin speedPin = new DialPointer.Pin(WIND_SPEED_DATASET_INDEX); speedPin.setPaint(WIND_SPEED_PIN_COLOR); speedPin.setRadius(WIND_SPEED_PIN_RADIUS); speedPin.setStroke(new BasicStroke(WIND_SPEED_PIN_WIDTH, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL)); plot.addPointer(speedPin); DialPointer.Pin gustPin = new DialPointer.Pin(WIND_GUST_DATASET_INDEX); gustPin.setPaint(WIND_GUST_PIN_COLOR); gustPin.setRadius(WIND_GUST_PIN_RADIUS); gustPin.setStroke(new BasicStroke(WIND_SPEED_PIN_WIDTH, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL)); plot.addPointer(gustPin); DialPointer.Pin maxSpeedPin = new DialPointer.Pin(MAX_WIND_SPEED_DATASET_INDEX); maxSpeedPin.setPaint(WIND_SPEED_PIN_COLOR); maxSpeedPin.setRadius(MAX_WIND_SPEED_PIN_RADIUS); maxSpeedPin .setStroke(new BasicStroke(MAX_WIND_SPEED_PIN_WIDTH, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL)); plot.addPointer(maxSpeedPin); DialPointer.Pin maxGustPin = new DialPointer.Pin(MAX_WIND_GUST_DATASET_INDEX); maxGustPin.setPaint(WIND_GUST_PIN_COLOR); maxGustPin.setRadius(MAX_WIND_GUST_PIN_RADIUS); maxGustPin .setStroke(new BasicStroke(MAX_WIND_SPEED_PIN_WIDTH, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL)); plot.addPointer(maxGustPin); speedAnnotation.setAngle(270.0); speedAnnotation.setRadius(.35); speedAnnotation.setPaint(Color.cyan); plot.addLayer(speedAnnotation); double angle = speedAnnotation.getAngle(); double radius = speedAnnotation.getRadius(); avgAnnotation.setPaint(Color.cyan); avgAnnotation.setAngle(angle); avgAnnotation.setRadius(radius + .1); plot.addLayer(avgAnnotation); for (int i = 0; i < WIND_DIR_ITEMS; i++) plot.mapDatasetToScale(WIND_DIR_DATASET_INDEX_BASE + i, WIND_DIR_SCALE); plot.mapDatasetToScale(WIND_SPEED_DATASET_INDEX, WIND_SPEED_SCALE); plot.mapDatasetToScale(WIND_GUST_DATASET_INDEX, WIND_SPEED_SCALE); plot.mapDatasetToScale(MAX_WIND_SPEED_DATASET_INDEX, WIND_SPEED_SCALE); plot.mapDatasetToScale(MAX_WIND_GUST_DATASET_INDEX, WIND_SPEED_SCALE); StandardDialRange range = new StandardDialRange(0.0, 360.0, Color.BLACK); range.setInnerRadius(.70); range.setOuterRadius(.72); range.setScaleIndex(WIND_DIR_SCALE); plot.addLayer(range); JFreeChart chart = new JFreeChart(plot); chart.setBackgroundPaint(Color.GRAY); chartViewer = new ChartViewer(chart); //chartViewer.setMinHeight(100); //chartViewer.setMinWidth(100); //chartViewer.setMaxHeight(400); //chartViewer.setMaxWidth(400); //chartViewer.setBackground(Color.GRAY); //chartViewer.setBorder(new BevelBorder(BevelBorder.RAISED)); this.setCenter(chartViewer); this.setTop(title); BorderPane.setAlignment(title, Pos.CENTER); title.textProperty().bind(titleProperty); setTitle("Wind"); timeline.setCycleCount(9); timeline.setOnFinished((event) -> { datasets[0].setValue(currentHeading); speedDataset.setValue(currentSpeed); lastHeading = currentHeading; lastSpeed = currentSpeed; }); }
From source file:net.sf.dynamicreports.test.jasper.chart.XyBlockChartTest.java
@Override public void test() { super.test(); numberOfPagesTest(1);//ww w . j a v a 2 s . c om JFreeChart chart = getChart("summary.chart1", 0); XYItemRenderer renderer = chart.getXYPlot().getRenderer(); Assert.assertEquals("renderer", XYBlockRenderer.class, renderer.getClass()); Assert.assertEquals("block width", 1.1, ((XYBlockRenderer) renderer).getBlockWidth()); Assert.assertEquals("block height", 0.9, ((XYBlockRenderer) renderer).getBlockHeight()); Assert.assertEquals("block anchor", org.jfree.ui.RectangleAnchor.BOTTOM_LEFT, ((XYBlockRenderer) renderer).getBlockAnchor()); Assert.assertEquals("paintScale", LookupPaintScale.class, ((XYBlockRenderer) renderer).getPaintScale().getClass()); LookupPaintScale paintScale = (LookupPaintScale) ((XYBlockRenderer) renderer).getPaintScale(); Assert.assertEquals("paintScale default lower bound", 0.1, paintScale.getLowerBound()); Assert.assertEquals("paintScale default upper bound", 5d, paintScale.getUpperBound()); Assert.assertEquals("paintScale default paint", Color.WHITE, paintScale.getDefaultPaint()); Assert.assertEquals("paintScale paint 1", Color.RED, paintScale.getPaint(1)); Assert.assertEquals("paintScale paint 2", Color.GREEN, paintScale.getPaint(2)); Assert.assertEquals("paintScale paint 3", Color.BLUE, paintScale.getPaint(3)); LegendItemCollection legendItems = chart.getXYPlot().getLegendItems(); Assert.assertEquals("legend item 1 label", "1", legendItems.get(0).getLabel()); Assert.assertEquals("legend item 1 paint", Color.RED, legendItems.get(0).getFillPaint()); Assert.assertEquals("legend item 2 label", "2", legendItems.get(1).getLabel()); Assert.assertEquals("legend item 2 paint", Color.GREEN, legendItems.get(1).getFillPaint()); Assert.assertEquals("legend item 3 label", "3", legendItems.get(2).getLabel()); Assert.assertEquals("legend item 3 paint", Color.BLUE, legendItems.get(2).getFillPaint()); xyzChartDataTest(chart, 0, "serie0", new Number[][] { { 1d, 2d, 0d }, { 2d, 3d, 1d }, { 3d, 4d, 2d }, { 4d, 5d, 3d } }); chart = getChart("summary.chart2", 0); Axis axis = chart.getXYPlot().getDomainAxis(); Assert.assertEquals("category label", "category", 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()); 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()); }
From source file:org.apereo.learninganalytics.snapp.ClusteringDemo.java
private void setUpView(Graph<Integer, Number> grp, Map<Integer, String> name) { /*// www . j a v a 2s. c o m Factory<Number> vertexFactory = new Factory<Number>() { int n = 0; public Number create() { return n++; } }; Factory<Number> edgeFactory = new Factory<Number>() { int n = 0; public Number create() { return n++; } }; PajekNetReader<Graph<Number, Number>, Number,Number> pnr = new PajekNetReader<Graph<Number, Number>, Number,Number>(vertexFactory, edgeFactory); final Graph<Number,Number> graph = new SparseMultigraph<Number, Number>(); pnr.load(br, graph); */ //Create a simple layout frame //specify the Fruchterman-Rheingold layout algorithm this.usernames = name; final AggregateLayout<Integer, Number> layout = new AggregateLayout<Integer, Number>( new FRLayout<Integer, Number>(grp)); layout.setSize(new Dimension(500, 500)); vv = new VisualizationViewer<Integer, Number>(layout); vv.setBackground(Color.white); //Tell the renderer to use our own customized color rendering vv.getRenderContext() .setVertexFillPaintTransformer(MapTransformer.<Integer, Paint>getInstance(vertexPaints)); vv.getRenderContext().setVertexDrawPaintTransformer(new Transformer<Integer, Paint>() { public Paint transform(Integer v) { if (vv.getPickedVertexState().isPicked(v)) { return Color.cyan; } else { return Color.BLACK; } } }); vv.getRenderContext().setEdgeDrawPaintTransformer(MapTransformer.<Number, Paint>getInstance(edgePaints)); vv.getRenderContext().setEdgeStrokeTransformer(new Transformer<Number, Stroke>() { protected final Stroke THIN = new BasicStroke(1); protected final Stroke THICK = new BasicStroke(2); public Stroke transform(Number e) { Paint c = edgePaints.get(e); if (c == Color.LIGHT_GRAY) return THIN; else return THICK; } }); vv.getRenderContext().setVertexLabelTransformer( // this chains together Transformers so that the html tags // are prepended to the toString method output new ChainedTransformer<Integer, String>( new Transformer[] { new ToStringLabeller<String>(), new Transformer<String, String>() { public String transform(String input) { return usernames.get(Integer.parseInt(input)); } } })); vv.getRenderer().getVertexLabelRenderer().setPosition(Renderer.VertexLabel.Position.S); /* //add restart button JButton scramble = new JButton("Restart"); scramble.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { Layout layout = vv.getGraphLayout(); layout.initialize(); Relaxer relaxer = vv.getModel().getRelaxer(); if(relaxer != null) { relaxer.stop(); relaxer.prerelax(); relaxer.relax(); } } }); */ DefaultModalGraphMouse gm = new DefaultModalGraphMouse(); vv.setGraphMouse(gm); final JToggleButton groupVertices = new JToggleButton("Group Clusters"); //Create slider to adjust the number of edges to remove when clustering final JSlider edgeBetweennessSlider = new JSlider(JSlider.HORIZONTAL); edgeBetweennessSlider.setBackground(Color.WHITE); edgeBetweennessSlider.setPreferredSize(new Dimension(210, 50)); edgeBetweennessSlider.setPaintTicks(true); edgeBetweennessSlider.setMaximum(grp.getEdgeCount()); edgeBetweennessSlider.setMinimum(0); edgeBetweennessSlider.setValue(0); edgeBetweennessSlider.setMajorTickSpacing(10); edgeBetweennessSlider.setPaintLabels(true); edgeBetweennessSlider.setPaintTicks(true); // edgeBetweennessSlider.setBorder(BorderFactory.createLineBorder(Color.black)); //TO DO: edgeBetweennessSlider.add(new JLabel("Node Size (PageRank With Priors):")); //I also want the slider value to appear final JPanel eastControls = new JPanel(); eastControls.setOpaque(true); eastControls.setLayout(new BoxLayout(eastControls, BoxLayout.Y_AXIS)); eastControls.add(Box.createVerticalGlue()); eastControls.add(edgeBetweennessSlider); final String COMMANDSTRING = "Edges removed for clusters: "; final String eastSize = COMMANDSTRING + edgeBetweennessSlider.getValue(); final TitledBorder sliderBorder = BorderFactory.createTitledBorder(eastSize); eastControls.setBorder(sliderBorder); //eastControls.add(eastSize); eastControls.add(Box.createVerticalGlue()); groupVertices.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { clusterAndRecolor(layout, edgeBetweennessSlider.getValue(), similarColors, e.getStateChange() == ItemEvent.SELECTED); vv.repaint(); } }); clusterAndRecolor(layout, 0, similarColors, groupVertices.isSelected()); edgeBetweennessSlider.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent e) { JSlider source = (JSlider) e.getSource(); if (!source.getValueIsAdjusting()) { int numEdgesToRemove = source.getValue(); clusterAndRecolor(layout, numEdgesToRemove, similarColors, groupVertices.isSelected()); sliderBorder.setTitle(COMMANDSTRING + edgeBetweennessSlider.getValue()); eastControls.repaint(); vv.validate(); vv.repaint(); } } }); // Add a restart button so the graph can be redrawn to fit the size of the frame JFrame jf = new JFrame("SNAPP: Find Clusters"); //jf.getContentPane().add(); //Container content = getContentPane(); //content.add(new GraphZoomScrollPane(vv)); jf.getContentPane().add(new GraphZoomScrollPane(vv)); JPanel south = new JPanel(); JPanel grid = new JPanel(new GridLayout(2, 1)); //grid.add(scramble); grid.add(groupVertices); south.add(grid); south.add(eastControls); JPanel p = new JPanel(); p.setBorder(BorderFactory.createTitledBorder("Mouse Mode")); p.add(gm.getModeComboBox()); south.add(p); //content.add(south, BorderLayout.SOUTH); jf.getContentPane().add(south, BorderLayout.SOUTH); //jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); jf.pack(); jf.setVisible(true); }