Example usage for java.awt Color orange

List of usage examples for java.awt Color orange

Introduction

In this page you can find the example usage for java.awt Color orange.

Prototype

Color orange

To view the source code for java.awt Color orange.

Click Source Link

Document

The color orange.

Usage

From source file:nl.ru.ai.projects.parrot.biomav.editor.BehaviorEditor.java

public BehaviorEditor() {
    ///////// Graph stuff
    graphViewer.addKeyListener(new KeyListener() {
        @Override//from   w ww  . j  a  va2  s  .  c o  m
        public void keyTyped(KeyEvent e) {
        }

        @Override
        public void keyReleased(KeyEvent e) {
        }

        @Override
        public void keyPressed(KeyEvent e) {
            if (e.getKeyCode() == KeyEvent.VK_DELETE) {
                for (TransitionEdge edge : graphViewer.getPickedEdgeState().getPicked()) {
                    graph.removeEdge(edge);
                }
                for (BehaviorVertex vertex : graphViewer.getPickedVertexState().getPicked()) {
                    graph.removeVertex(vertex);
                }
                e.consume();
                repaint();
            }
        }
    });

    graphViewer.setBackground(Color.GRAY);

    graphViewer.setGraphMouse(graphMouse);
    graphMouse.add(graphMouseEditPlugin);
    graphMouse.add(graphMouseTranslatePlugin);
    graphMouse.add(graphMousePickPlugin);

    // Set label renderer
    VertexLabelAsShapeRenderer<BehaviorVertex, TransitionEdge> renderer = new VertexLabelAsShapeRenderer<BehaviorVertex, TransitionEdge>(
            graphViewer.getRenderContext());
    graphViewer.getRenderContext().setVertexShapeTransformer(renderer);
    graphViewer.getRenderer().setVertexLabelRenderer(renderer);

    // Set label contents
    graphViewer.getRenderContext().setVertexLabelTransformer(new Transformer<BehaviorVertex, String>() {
        @Override
        public String transform(BehaviorVertex v) {
            return v.getSelectedBehavior();
        }
    });
    graphViewer.getRenderContext().setEdgeLabelTransformer(new Transformer<TransitionEdge, String>() {
        @Override
        public String transform(TransitionEdge e) {
            return e.getTransition();
        }
    });

    // Set fonts
    graphViewer.getRenderContext().setVertexFontTransformer(new Transformer<BehaviorVertex, Font>() {
        @Override
        public Font transform(BehaviorVertex v) {
            return new Font(graphViewer.getFont().getName(), graphViewer.getFont().getStyle(), 20);
        }
    });
    graphViewer.getRenderContext().setEdgeFontTransformer(new Transformer<TransitionEdge, Font>() {
        @Override
        public Font transform(TransitionEdge arg0) {
            return new Font(graphViewer.getFont().getName(), graphViewer.getFont().getStyle(), 16);
        }
    });

    // Fill color dependent on vertex activity
    graphViewer.getRenderContext().setVertexFillPaintTransformer(new Transformer<BehaviorVertex, Paint>() {
        @Override
        public Paint transform(BehaviorVertex vertex) {
            return vertex.isActive() ? Color.ORANGE : Color.RED;
        }
    });

    graphViewer.getPickedVertexState().addItemListener(new ItemListener() {
        @Override
        public void itemStateChanged(ItemEvent e) {
            BehaviorVertex vertex = (BehaviorVertex) e.getItem();
            if (e.getStateChange() == ItemEvent.SELECTED) {
                setNewSelectedParameterControlInterface(vertex);
            }
            if (e.getStateChange() == ItemEvent.DESELECTED) {
                if (vertex == selectedPCInterface) {
                    setNewSelectedParameterControlInterface(null);
                }
            }
        }
    });
    graphViewer.getPickedEdgeState().addItemListener(new ItemListener() {
        @Override
        public void itemStateChanged(ItemEvent e) {
            TransitionEdge edge = (TransitionEdge) e.getItem();
            if (e.getStateChange() == ItemEvent.SELECTED) {
                setNewSelectedParameterControlInterface(edge);
            }
            if (e.getStateChange() == ItemEvent.DESELECTED) {
                if (edge == selectedPCInterface) {
                    setNewSelectedParameterControlInterface(null);
                }
            }
        }
    });

    this.addComponentListener(new ComponentListener() {
        @Override
        public void componentShown(ComponentEvent e) {
        }

        @Override
        public void componentResized(ComponentEvent e) {
            graphViewer.getGraphLayout().setSize(graphViewer.getSize());
        }

        @Override
        public void componentMoved(ComponentEvent e) {
        }

        @Override
        public void componentHidden(ComponentEvent e) {
        }
    });

    ///////////// Side panel (parameter control)
    pcInterfacePanel.setPreferredSize(new Dimension(200, 0));
    pcInterfacePanel.setLayout(new BorderLayout());

    pcInterfacePanelContents.setLayout(new GridLayout(0, 2, 0, 5));
    pcInterfacePanel.add(pcInterfacePanelContents, BorderLayout.NORTH);

    ///////////// [this]

    setLayout(new BorderLayout(10, 10));

    add(graphViewer, BorderLayout.CENTER);
    add(pcInterfacePanel, BorderLayout.EAST);
}

From source file:MyLink.java

public JPanel printableKSGenerate() {
    // create a simple graph for the demo
    graph = new SparseMultigraph<Integer, MyLink>();

    Integer[] v = createVertices(getTermNum());
    createEdges(v);// w w  w  .  j  a va 2s  .c om

    vv = new VisualizationViewer<Integer, MyLink>(new KKLayout<Integer, MyLink>(graph));
    vv.setPreferredSize(new Dimension(520, 520)); // 570, 640 | 565, 640 

    vv.getRenderContext().setVertexLabelTransformer(new UnicodeVertexStringer<Integer>(v));
    vv.getRenderContext().setVertexLabelRenderer(new DefaultVertexLabelRenderer(Color.magenta));
    vv.getRenderContext().setEdgeLabelRenderer(new DefaultEdgeLabelRenderer(Color.magenta));
    VertexIconShapeTransformer<Integer> vertexIconShapeFunction = new VertexIconShapeTransformer<Integer>(
            new EllipseVertexShapeTransformer<Integer>());
    DefaultVertexIconTransformer<Integer> vertexIconFunction = new DefaultVertexIconTransformer<Integer>();
    vv.getRenderContext().setVertexShapeTransformer(vertexIconShapeFunction);
    vv.getRenderContext().setVertexIconTransformer(vertexIconFunction);
    loadImages(v, vertexIconFunction.getIconMap());
    vertexIconShapeFunction.setIconMap(vertexIconFunction.getIconMap());
    vv.getRenderContext().setVertexFillPaintTransformer(new PickableVertexPaintTransformer<Integer>(
            vv.getPickedVertexState(), new Color(0, 102, 255), Color.red));
    vv.getRenderContext().setEdgeDrawPaintTransformer(
            new PickableEdgePaintTransformer<MyLink>(vv.getPickedEdgeState(), Color.orange, Color.cyan));
    vv.setBackground(Color.white);

    final int maxSize = findMaxSizeNumber();

    File file = new File("./output/DESC_TERM_COUNT.txt");
    String s;

    try {
        BufferedReader fis = new BufferedReader(new InputStreamReader(new FileInputStream(file)));

        s = fis.readLine();
        userSelectedTermsCount = Integer.parseInt(s);
        termIndex = new int[userSelectedTermsCount];

        int i = 0;
        while ((s = fis.readLine()) != null) {
            String[] tmp = s.split("=");
            termIndex[i] = Integer.parseInt(tmp[1].trim());
            i++;
        }

    } catch (IOException e) {
        System.out.println(e.getMessage());
    }

    Transformer<Integer, Shape> vertexSize = new Transformer<Integer, Shape>() {
        public Shape transform(Integer i) {
            double sizeInt = termIndex[i];
            sizeInt = (double) sizeInt / (double) maxSize;
            sizeInt = (double) sizeInt * (double) 30 + 10;
            Ellipse2D circle = new Ellipse2D.Double(sizeInt / 2 * (-1), sizeInt / 2 * (-1), sizeInt, sizeInt);
            return circle;
        }
    };
    vv.getRenderContext().setVertexShapeTransformer(vertexSize);
    vv.getRenderer().getVertexLabelRenderer().setPosition(Position.N);

    // add my listener for ToolTips
    vv.setVertexToolTipTransformer(new ToStringLabeller<Integer>());

    // create a frome to hold the graph
    APanel = new JPanel();
    APanel.setLayout(new BoxLayout(APanel, BoxLayout.Y_AXIS));

    final GraphZoomScrollPane panel = new GraphZoomScrollPane(vv);

    final ModalGraphMouse gm = new DefaultModalGraphMouse<Integer, Number>();
    vv.setGraphMouse(gm);

    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 lo = new JCheckBox("Show Labels");
    lo.addItemListener(new ItemListener() {
        public void itemStateChanged(ItemEvent e) {
            showLabels = e.getStateChange() == ItemEvent.SELECTED;

            vv.repaint();
        }
    });
    lo.setSelected(true);

    JPanel controls = new JPanel();
    controls.add(plus);
    controls.add(minus);
    controls.add(lo);
    controls.add(((DefaultModalGraphMouse<Integer, Number>) gm).getModeComboBox());
    APanel.add(vv);
    APanel.add(controls);

    return APanel;
}

From source file:net.sf.fspdfs.chartthemes.simple.SimpleSettingsFactory.java

/**
 *
 *//*from www.j a v  a2 s.  c o m*/
public static final ChartThemeSettings createChartThemeSettings() {
    ChartThemeSettings settings = new ChartThemeSettings();

    ChartSettings chartSettings = settings.getChartSettings();
    chartSettings.setBackgroundPaint(new GradientPaintProvider(Color.green, Color.blue));
    chartSettings.setBackgroundImage(new FileImageProvider("net/sf/fspdfs/chartthemes/simple/fspdfs.png"));
    chartSettings.setBackgroundImageAlignment(new Integer(Align.TOP_RIGHT));
    chartSettings.setBackgroundImageAlpha(new Float(1f));
    chartSettings.setBorderVisible(Boolean.TRUE);
    chartSettings.setBorderPaint(new ColorProvider(Color.GREEN));
    chartSettings.setBorderStroke(new BasicStroke(1f));
    chartSettings.setAntiAlias(Boolean.TRUE);
    chartSettings.setTextAntiAlias(Boolean.TRUE);
    chartSettings.setPadding(new RectangleInsets(UnitType.ABSOLUTE, 1.1, 2.2, 3.3, 4.4));

    TitleSettings titleSettings = settings.getTitleSettings();
    titleSettings.setShowTitle(Boolean.TRUE);
    titleSettings.setPosition(EdgeEnum.TOP);
    titleSettings.setForegroundPaint(new ColorProvider(Color.black));
    titleSettings.setBackgroundPaint(new GradientPaintProvider(Color.green, Color.blue));
    titleSettings.getFont().setBold(Boolean.TRUE);
    titleSettings.getFont().setFontSize(22);
    titleSettings.setHorizontalAlignment(HorizontalAlignment.CENTER);
    titleSettings.setVerticalAlignment(VerticalAlignment.TOP);
    titleSettings.setPadding(new RectangleInsets(UnitType.ABSOLUTE, 1.1, 2.2, 3.3, 4.4));

    TitleSettings subtitleSettings = settings.getSubtitleSettings();
    subtitleSettings.setShowTitle(Boolean.TRUE);
    subtitleSettings.setPosition(EdgeEnum.TOP);
    subtitleSettings.setForegroundPaint(new ColorProvider(Color.red));
    subtitleSettings.setBackgroundPaint(new GradientPaintProvider(Color.green, Color.blue));
    subtitleSettings.getFont().setBold(Boolean.TRUE);
    subtitleSettings.setHorizontalAlignment(HorizontalAlignment.LEFT);
    subtitleSettings.setVerticalAlignment(VerticalAlignment.CENTER);
    subtitleSettings.setPadding(new RectangleInsets(UnitType.ABSOLUTE, 1.1, 2.2, 3.3, 4.4));

    LegendSettings legendSettings = settings.getLegendSettings();
    legendSettings.setShowLegend(Boolean.TRUE);
    legendSettings.setPosition(EdgeEnum.BOTTOM);
    legendSettings.setForegroundPaint(new ColorProvider(Color.black));
    legendSettings.setBackgroundPaint(new GradientPaintProvider(Color.green, Color.blue));
    legendSettings.getFont().setBold(Boolean.TRUE);
    legendSettings.setHorizontalAlignment(HorizontalAlignment.CENTER);
    legendSettings.setVerticalAlignment(VerticalAlignment.BOTTOM);
    //FIXMETHEME legendSettings.setBlockFrame();
    legendSettings.setPadding(new RectangleInsets(UnitType.ABSOLUTE, 1.1, 2.2, 3.3, 4.4));

    PlotSettings plotSettings = settings.getPlotSettings();
    plotSettings.setOrientation(PlotOrientation.VERTICAL);
    //      plotSettings.setForegroundAlpha(new Float(0.5f));
    plotSettings.setBackgroundPaint(new GradientPaintProvider(Color.green, Color.blue));
    //      plotSettings.setBackgroundAlpha(new Float(0.5f));
    plotSettings.setBackgroundImage(new FileImageProvider("net/sf/fspdfs/chartthemes/simple/fspdfs.png"));
    plotSettings.setBackgroundImageAlpha(new Float(0.5f));
    plotSettings.setBackgroundImageAlignment(new Integer(Align.NORTH_WEST));
    plotSettings.setLabelRotation(new Double(0));
    plotSettings.setPadding(new RectangleInsets(UnitType.ABSOLUTE, 1.1, 2.2, 3.3, 4.4));
    plotSettings.setOutlineVisible(Boolean.TRUE);
    plotSettings.setOutlinePaint(new ColorProvider(Color.red));
    plotSettings.setOutlineStroke(new BasicStroke(1f));
    plotSettings.setSeriesColorSequence(COLORS);
    //      plotSettings.setSeriesGradientPaintSequence(GRADIENT_PAINTS);
    plotSettings.setSeriesOutlinePaintSequence(COLORS_DARKER);
    plotSettings.setSeriesStrokeSequence(STROKES);
    plotSettings.setSeriesOutlineStrokeSequence(OUTLINE_STROKES);
    plotSettings.setDomainGridlineVisible(Boolean.TRUE);
    plotSettings.setDomainGridlinePaint(new ColorProvider(Color.DARK_GRAY));
    plotSettings.setDomainGridlineStroke(new BasicStroke(0.5f));
    plotSettings.setRangeGridlineVisible(Boolean.TRUE);
    plotSettings.setRangeGridlinePaint(new ColorProvider(Color.BLACK));
    plotSettings.setRangeGridlineStroke(new BasicStroke(0.5f));
    plotSettings.getTickLabelFont().setFontName("Courier");
    plotSettings.getTickLabelFont().setBold(Boolean.TRUE);
    plotSettings.getTickLabelFont().setFontSize(10);
    plotSettings.getDisplayFont().setFontName("Arial");
    plotSettings.getDisplayFont().setBold(Boolean.TRUE);
    plotSettings.getDisplayFont().setFontSize(12);

    AxisSettings domainAxisSettings = settings.getDomainAxisSettings();
    domainAxisSettings.setVisible(Boolean.TRUE);
    domainAxisSettings.setLocation(AxisLocation.BOTTOM_OR_RIGHT);
    domainAxisSettings.setLinePaint(new ColorProvider(Color.green));
    domainAxisSettings.setLineStroke(new BasicStroke(1f));
    domainAxisSettings.setLineVisible(Boolean.TRUE);
    //      domainAxisSettings.setLabel("Domain Axis");
    domainAxisSettings.setLabelAngle(new Double(0.0));
    domainAxisSettings.setLabelPaint(new ColorProvider(Color.magenta));
    domainAxisSettings.getLabelFont().setBold(Boolean.TRUE);
    domainAxisSettings.getLabelFont().setItalic(Boolean.TRUE);
    domainAxisSettings.getLabelFont().setFontName("Comic Sans MS");
    domainAxisSettings.getLabelFont().setFontSize(12);
    domainAxisSettings.setLabelInsets(new RectangleInsets(UnitType.ABSOLUTE, 0.5, 0.5, 1, 1));
    domainAxisSettings.setLabelVisible(Boolean.TRUE);
    domainAxisSettings.setTickLabelPaint(new ColorProvider(Color.cyan));
    domainAxisSettings.getTickLabelFont().setBold(Boolean.TRUE);
    domainAxisSettings.getTickLabelFont().setItalic(Boolean.FALSE);
    domainAxisSettings.getTickLabelFont().setFontName("Arial");
    domainAxisSettings.getTickLabelFont().setFontSize(10);
    domainAxisSettings.setTickLabelInsets(new RectangleInsets(UnitType.ABSOLUTE, 0.5, 0.5, 0.5, 0.5));
    domainAxisSettings.setTickLabelsVisible(Boolean.TRUE);
    domainAxisSettings.setTickMarksInsideLength(new Float(0.1f));
    domainAxisSettings.setTickMarksOutsideLength(new Float(0.2f));
    domainAxisSettings.setTickMarksPaint(new ColorProvider(Color.ORANGE));
    domainAxisSettings.setTickMarksStroke(new BasicStroke(1f));
    domainAxisSettings.setTickMarksVisible(Boolean.TRUE);
    domainAxisSettings.setTickCount(new Integer(5));

    AxisSettings rangeAxisSettings = settings.getRangeAxisSettings();
    rangeAxisSettings.setVisible(Boolean.TRUE);
    rangeAxisSettings.setLocation(AxisLocation.TOP_OR_RIGHT);
    rangeAxisSettings.setLinePaint(new ColorProvider(Color.yellow));
    rangeAxisSettings.setLineStroke(new BasicStroke(1f));
    rangeAxisSettings.setLineVisible(Boolean.TRUE);
    //      rangeAxisSettings.setLabel("Range Axis");
    rangeAxisSettings.setLabelAngle(new Double(Math.PI / 2.0));
    rangeAxisSettings.setLabelPaint(new ColorProvider(Color.green));
    rangeAxisSettings.getLabelFont().setBold(Boolean.TRUE);
    rangeAxisSettings.getLabelFont().setItalic(Boolean.TRUE);
    rangeAxisSettings.getLabelFont().setFontName("Comic Sans MS");
    rangeAxisSettings.getLabelFont().setFontSize(12);
    rangeAxisSettings.setLabelInsets(new RectangleInsets(UnitType.ABSOLUTE, 0.5, 0.5, 1, 1));
    rangeAxisSettings.setLabelVisible(Boolean.TRUE);
    rangeAxisSettings.setTickLabelPaint(new ColorProvider(Color.pink));
    rangeAxisSettings.getTickLabelFont().setBold(Boolean.FALSE);
    rangeAxisSettings.getTickLabelFont().setItalic(Boolean.TRUE);
    rangeAxisSettings.getTickLabelFont().setFontName("Arial");
    rangeAxisSettings.getTickLabelFont().setFontSize(10);
    rangeAxisSettings.setTickLabelInsets(new RectangleInsets(UnitType.ABSOLUTE, 0.5, 0.5, 0.5, 0.5));
    rangeAxisSettings.setTickLabelsVisible(Boolean.TRUE);
    rangeAxisSettings.setTickMarksInsideLength(new Float(0.2f));
    rangeAxisSettings.setTickMarksOutsideLength(new Float(0.1f));
    rangeAxisSettings.setTickMarksPaint(new ColorProvider(Color.black));
    rangeAxisSettings.setTickMarksStroke(new BasicStroke(1f));
    rangeAxisSettings.setTickMarksVisible(Boolean.TRUE);
    rangeAxisSettings.setTickCount(new Integer(6));

    return settings;
}

From source file:com.polivoto.vistas.acciones.Datos.java

private void setcolors() {
    colores.add(Color.red);//from w w w . ja v  a 2 s . c  om
    colores.add(Color.green);
    colores.add(Color.blue);
    colores.add(Color.yellow);
    colores.add(Color.magenta);
    colores.add(Color.cyan);
    colores.add(Color.pink);
    colores.add(Color.orange);
    colores.add(Color.darkGray);
    colores.add(Color.white);
}

From source file:dpfmanager.conformancechecker.tiff.reporting.PdfReport.java

/**
 * Parse an individual report to PDF./*ww w. j ava2  s .c o m*/
 *
 * @param ir the individual report.
 */
public void parseIndividual(IndividualReport ir) {
    try {
        PDFParams pdfParams = new PDFParams();
        pdfParams.init(PDPage.PAGE_SIZE_A4);
        PDFont font = PDType1Font.HELVETICA_BOLD;

        int pos_x = 200;
        pdfParams.y = 700;
        int font_size = 18;

        // Logo
        PDXObjectImage ximage;
        float scale = 3;
        synchronized (this) {
            InputStream inputStream = getFileStreamFromResources("images/logo.jpg");
            ximage = null;
            try {
                ximage = new PDJpeg(pdfParams.getDocument(), inputStream);
            } catch (Exception ex) {
                ex.printStackTrace();
            }
            if (ximage != null)
                pdfParams.getContentStream().drawXObject(ximage, pos_x, pdfParams.y, 645 / scale, 300 / scale);
        }

        // Report Title
        pdfParams.y -= 30;
        pdfParams = writeText(pdfParams, "INDIVIDUAL REPORT", pos_x, font, font_size);

        // Image
        pos_x = 50;
        int max_image_height = 130;
        int max_image_width = 200;
        pdfParams.y -= (max_image_height + 30);
        int image_pos_y = pdfParams.y;
        BufferedImage thumb = tiff2Jpg(ir.getFilePath());
        if (thumb == null) {
            thumb = ImageIO.read(getFileStreamFromResources("html/img/noise.jpg"));
        }
        int image_height = thumb.getHeight();
        int image_width = thumb.getWidth();
        if (image_height > max_image_height) {
            image_width = max_image_height * image_width / image_height;
            image_height = max_image_height;
        }
        if (image_width > max_image_width) {
            image_height = max_image_width * image_height / image_width;
            image_width = max_image_width;
        }
        ximage = new PDJpeg(pdfParams.getDocument(), thumb);
        pdfParams.getContentStream().drawXObject(ximage, pos_x, pdfParams.y, image_width, image_height);
        image_width = max_image_width;

        /**
         * Image name and path
         */
        font_size = 12;
        pdfParams.y += image_height - 12;
        pdfParams = writeText(pdfParams, ir.getFileName(), pos_x + image_width + 10, font, font_size);
        font_size = 11;
        pdfParams.y -= 32;
        List<String> linesPath = splitInLines(font_size, font, ir.getFilePath().replaceAll("\\\\", "/"),
                490 - image_width, "/");
        for (String line : linesPath) {
            pdfParams = writeText(pdfParams, line, pos_x + image_width + 10, font, font_size);
            pdfParams.y -= 10;
        }

        // Image alert
        pdfParams.y -= 30;
        font_size = 9;
        for (String iso : ir.getCheckedIsos()) {
            if (ir.hasValidation(iso) || ir.getNErrors(iso) == 0) {
                String name = ImplementationCheckerLoader.getIsoName(iso);
                pdfParams = makeConformSection(ir.getNErrors(iso), ir.getNWarnings(iso), name, pdfParams, pos_x,
                        image_width, font_size, font);
            }
        }
        pdfParams.y -= 10;

        /**
         * Summary table
         */
        font_size = 8;
        pdfParams = writeText(pdfParams, "Errors", pos_x + image_width + 170, font, font_size);
        pdfParams = writeText(pdfParams, "Warnings", pos_x + image_width + 210, font, font_size);
        String dif = "";

        for (String iso : ir.getCheckedIsos()) {
            if (ir.hasValidation(iso) || ir.getNErrors(iso) == 0) {
                String name = ImplementationCheckerLoader.getIsoName(iso);
                pdfParams.y -= 20;
                pdfParams.getContentStream().drawLine(pos_x + image_width + 10, pdfParams.y + 15,
                        pos_x + image_width + 260, pdfParams.y + 15);
                pdfParams = writeText(pdfParams, name, pos_x + image_width + 10, font, font_size);
                dif = ir.getCompareReport() != null
                        ? getDif(ir.getCompareReport().getNErrors(iso), ir.getNErrors(iso))
                        : "";
                pdfParams = writeText(pdfParams, ir.getNErrors(iso) + dif, pos_x + image_width + 180, font,
                        font_size, ir.getNErrors(iso) > 0 ? Color.red : Color.black);
                dif = ir.getCompareReport() != null
                        ? getDif(ir.getCompareReport().getNWarnings(iso), ir.getNWarnings(iso))
                        : "";
                pdfParams = writeText(pdfParams, ir.getNWarnings(iso) + dif, pos_x + image_width + 230, font,
                        font_size, ir.getNWarnings(iso) > 0 ? Color.orange : Color.black);
            }
        }

        if (pdfParams.y > image_pos_y)
            pdfParams.y = image_pos_y;

        /**
         * File structure
         */
        font_size = 10;
        pdfParams.y -= 40;
        pdfParams = writeTitle(pdfParams, "File Structure", "images/pdf/site.png", pos_x, font, font_size);
        TiffDocument td = ir.getTiffModel();
        IFD ifd = td.getFirstIFD();
        font_size = 7;
        while (ifd != null) {
            pdfParams.y -= 20;
            String typ = " - Main image";
            if (ifd.hasSubIFD() && ifd.getImageSize() < ifd.getsubIFD().getImageSize())
                typ = " - Thumbnail";
            ximage = new PDJpeg(pdfParams.getDocument(), getFileStreamFromResources("images/doc.jpg"));
            pdfParams.getContentStream().drawXObject(ximage, pos_x, pdfParams.y, 5, 7);
            pdfParams = writeText(pdfParams, ifd.toString() + typ, pos_x + 7, font, font_size);
            if (ifd.getsubIFD() != null) {
                pdfParams.y -= 18;
                if (ifd.getImageSize() < ifd.getsubIFD().getImageSize())
                    typ = " - Main image";
                else
                    typ = " - Thumbnail";
                pdfParams.getContentStream().drawXObject(ximage, pos_x + 15, pdfParams.y, 5, 7);
                pdfParams = writeText(pdfParams, "SubIFD" + typ, pos_x + 15 + 7, font, font_size);
            }
            if (ifd.containsTagId(34665)) {
                pdfParams.y -= 18;
                pdfParams.getContentStream().drawXObject(ximage, pos_x + 15, pdfParams.y, 5, 7);
                pdfParams = writeText(pdfParams, "EXIF", pos_x + 15 + 7, font, font_size);
            }
            if (ifd.containsTagId(700)) {
                pdfParams.y -= 18;
                pdfParams.getContentStream().drawXObject(ximage, pos_x + 15, pdfParams.y, 5, 7);
                pdfParams = writeText(pdfParams, "XMP", pos_x + 15 + 7, font, font_size);
            }
            if (ifd.containsTagId(33723)) {
                pdfParams.y -= 18;
                pdfParams.getContentStream().drawXObject(ximage, pos_x + 15, pdfParams.y, 5, 7);
                pdfParams = writeText(pdfParams, "IPTC", pos_x + 15 + 7, font, font_size);
            }
            ifd = ifd.getNextIFD();
        }

        /**
         * Tags
         */
        font_size = 7;
        Map<String, List<ReportTag>> tags = parseTags(ir);
        for (String key : sortByTag(tags.keySet())) {
            /**
             * IFD
             */
            if (key.startsWith("ifd") && !key.endsWith("e")) {
                pdfParams.y -= 40;
                pdfParams = writeTitle(pdfParams, "IFD Tags", "images/pdf/tag.png", pos_x, font, 10);
                pdfParams.y -= 20;
                Integer[] margins = { 2, 40, 180 };
                pdfParams = writeTableHeaders(pdfParams, pos_x, font_size, font,
                        Arrays.asList("ID", "Name", "Value"), margins);
                for (ReportTag tag : tags.get(key)) {
                    pdfParams.y -= 15;
                    String sDif = "";
                    if (tag.dif < 0)
                        sDif = "(-)";
                    else if (tag.dif > 0)
                        sDif = "(+)";
                    pdfParams = writeText(pdfParams, tag.tv.getId() + sDif, pos_x + margins[0], font,
                            font_size);
                    pdfParams = writeText(pdfParams,
                            (tag.tv.getName().equals(tag.tv.getId() + "") ? "Private tag" : tag.tv.getName()),
                            pos_x + margins[1], font, font_size);
                    pdfParams = writeText(pdfParams, tag.tv.getDescriptiveValue(), pos_x + margins[2], font,
                            font_size);
                }
            }
            /**
             * IFD  expert
             */
            else if (key.startsWith("ifd")) {
                pdfParams.y -= 40;
                pdfParams = writeTitle(pdfParams, "IFD Expert Tags", "images/pdf/tag.png", pos_x, font, 10);
                pdfParams.y -= 20;
                Integer[] margins = { 2, 40, 180 };
                pdfParams = writeTableHeaders(pdfParams, pos_x, font_size, font,
                        Arrays.asList("ID", "Name", "Value"), margins);
                for (ReportTag tag : tags.get(key)) {
                    pdfParams.y -= 15;
                    String sDif = "";
                    if (tag.dif < 0)
                        sDif = "(-)";
                    else if (tag.dif > 0)
                        sDif = "(+)";
                    pdfParams = writeText(pdfParams, tag.tv.getId() + sDif, pos_x + margins[0], font,
                            font_size);
                    pdfParams = writeText(pdfParams,
                            (tag.tv.getName().equals(tag.tv.getId() + "") ? "Private tag" : tag.tv.getName()),
                            pos_x + margins[1], font, font_size);
                    pdfParams = writeText(pdfParams, tag.tv.getDescriptiveValue(), pos_x + margins[2], font,
                            font_size);
                }
            }
            /**
             * SUB
             */
            if (key.startsWith("sub")) {
                for (ReportTag tag : tags.get(key)) {
                    pdfParams.y -= 40;
                    pdfParams = writeTitle(pdfParams, "Sub IFD Tags", "images/pdf/tag.png", pos_x, font, 10);
                    pdfParams.y -= 20;
                    Integer[] margins = { 2, 40, 180 };
                    pdfParams = writeTableHeaders(pdfParams, pos_x, font_size, font,
                            Arrays.asList("ID", "Name", "Value"), margins);
                    IFD sub = (IFD) tag.tv.getValue().get(0);
                    for (TagValue tv : sub.getTags().getTags()) {
                        pdfParams.y -= 15;
                        pdfParams = writeText(pdfParams, tv.getId() + "", pos_x + margins[0], font, font_size);
                        pdfParams = writeText(pdfParams,
                                (tv.getName().equals(tv.getId() + "") ? "Private tag" : tv.getName()),
                                pos_x + margins[1], font, font_size);
                        pdfParams = writeText(pdfParams, tv.getDescriptiveValue(), pos_x + margins[2], font,
                                font_size);
                    }
                }
            }
            /**
             * EXIF
             */
            if (key.startsWith("exi")) {
                for (ReportTag tag : tags.get(key)) {
                    pdfParams.y -= 40;
                    String index = (tag.index > 0) ? " (IFD " + tag.index + ")" : "";
                    pdfParams = writeTitle(pdfParams, "EXIF Tags" + index, "images/pdf/tag.png", pos_x, font,
                            10);
                    pdfParams.y -= 20;
                    Integer[] margins = { 2, 40, 180 };
                    pdfParams = writeTableHeaders(pdfParams, pos_x, font_size, font,
                            Arrays.asList("ID", "Name", "Value"), margins);
                    IFD exif = (IFD) tag.tv.getValue().get(0);
                    for (TagValue tv : exif.getTags().getTags()) {
                        pdfParams.y -= 15;
                        pdfParams = writeText(pdfParams, tv.getId() + "", pos_x + margins[0], font, font_size);
                        pdfParams = writeText(pdfParams,
                                (tv.getName().equals(tv.getId() + "") ? "Private tag" : tv.getName()),
                                pos_x + margins[1], font, font_size);
                        pdfParams = writeText(pdfParams, tv.getDescriptiveValue(), pos_x + margins[2], font,
                                font_size);
                    }
                }
            }
            /**
             * IPTC
             */
            if (key.startsWith("ipt")) {
                for (ReportTag tag : tags.get(key)) {
                    pdfParams.y -= 40;
                    String index = (tag.index > 0) ? " (IFD " + tag.index + ")" : "";
                    pdfParams = writeTitle(pdfParams, "IPTC Tags" + index, "images/pdf/tag.png", pos_x, font,
                            10);
                    pdfParams.y -= 20;
                    Integer[] margins = { 2, 180 };
                    pdfParams = writeTableHeaders(pdfParams, pos_x, font_size, font,
                            Arrays.asList("Name", "Value"), margins);
                    abstractTiffType obj = tag.tv.getValue().get(0);
                    if (obj instanceof IPTC) {
                        IPTC iptc = (IPTC) obj;
                        Metadata metadata = iptc.createMetadata();
                        for (String mKey : iptc.createMetadata().keySet()) {
                            pdfParams.y -= 15;
                            pdfParams = writeText(pdfParams, mKey, pos_x + margins[0], font, font_size);
                            pdfParams = writeText(pdfParams, metadata.get(mKey).toString().trim(),
                                    pos_x + margins[1], font, font_size);
                        }
                    }
                }
            }
            /**
             * XMP
             */
            if (key.startsWith("xmp")) {
                for (ReportTag tag : tags.get(key)) {
                    // Tags
                    pdfParams.y -= 40;
                    String index = (tag.index > 0) ? " (IFD " + tag.index + ")" : "";
                    pdfParams = writeTitle(pdfParams, "XMP Tags" + index, "images/pdf/tag.png", pos_x, font,
                            10);
                    pdfParams.y -= 20;
                    Integer[] margins = { 2, 180 };
                    pdfParams = writeTableHeaders(pdfParams, pos_x, font_size, font,
                            Arrays.asList("Name", "Value"), margins);
                    XMP xmp = (XMP) tag.tv.getValue().get(0);
                    Metadata metadata = xmp.createMetadata();
                    for (String xKey : metadata.keySet()) {
                        pdfParams.y -= 15;
                        pdfParams = writeText(pdfParams, xKey, pos_x + margins[0], font, font_size);
                        pdfParams = writeText(pdfParams, metadata.get(xKey).toString().trim(),
                                pos_x + margins[1], font, font_size);
                    }
                    // History
                    if (xmp.getHistory() != null) {
                        pdfParams.y -= 40;
                        pdfParams = writeTitle(pdfParams, "History" + index, "images/pdf/tag.png", pos_x, font,
                                10);
                        pdfParams.y -= 20;
                        pdfParams = writeTableHeaders(pdfParams, pos_x, font_size, font,
                                Arrays.asList("Attribute", "Value"), margins);
                        int nh = 0;
                        for (Hashtable<String, String> kv : xmp.getHistory()) {
                            // TODO WORKARROUND
                            String hKey = kv.keySet().iterator().next();
                            if (hKey.equals("action") && nh != 0) {
                                pdfParams.getContentStream().drawLine(pos_x, pdfParams.y - 5, pos_x + 490,
                                        pdfParams.y - 5);
                            }
                            pdfParams.y -= 15;
                            pdfParams = writeText(pdfParams, hKey, pos_x + margins[0], font, font_size);
                            pdfParams = writeText(pdfParams, kv.get(hKey).toString().trim(), pos_x + margins[1],
                                    font, font_size);
                            nh++;
                        }
                    }
                }
            }
        }

        /**
         * Metadata incoherencies
         */
        pdfParams.y -= 40;
        pdfParams = writeTitle(pdfParams, "Metadata analysis", "images/pdf/metadata.png", pos_x, font, 10);
        pdfParams.y -= 20;
        Integer[] margins = { 2, 30 };
        pdfParams = writeTableHeaders(pdfParams, pos_x, font_size, font, Arrays.asList("", "Description"),
                margins);
        IFD tdifd = td.getFirstIFD();
        int nifd = 1;
        List<String> rows = new ArrayList<>();
        while (tdifd != null) {
            XMP xmp = null;
            IPTC iptc = null;
            if (tdifd.containsTagId(TiffTags.getTagId("XMP")))
                xmp = (XMP) tdifd.getTag("XMP").getValue().get(0);
            if (tdifd.containsTagId(TiffTags.getTagId("IPTC"))) {
                abstractTiffType obj = tdifd.getTag("IPTC").getValue().get(0);
                if (obj instanceof IPTC) {
                    iptc = (IPTC) obj;
                }
            }

            // Author
            String authorTag = null;
            if (tdifd.containsTagId(TiffTags.getTagId("Artist")))
                authorTag = tdifd.getTag("Artist").toString();
            String authorIptc = null;
            if (iptc != null)
                authorIptc = iptc.getCreator();
            String authorXmp = null;
            if (xmp != null)
                authorXmp = xmp.getCreator();

            rows.addAll(detectIncoherency(authorTag, authorIptc, authorXmp, "Author", nifd));
            tdifd = tdifd.getNextIFD();
            nifd++;
        }
        if (rows.isEmpty()) {
            pdfParams.y -= 15;
            PDPixelMap titleImage = new PDPixelMap(pdfParams.getDocument(),
                    ImageIO.read(getFileStreamFromResources("images/pdf/check.png")));
            pdfParams.getContentStream().drawXObject(titleImage, pos_x + 5, pdfParams.y - 1, 9, 9);
            pdfParams = writeText(pdfParams, "No metadata incoherencies found", pos_x + margins[1], font,
                    font_size);
        }
        for (String row : rows) {
            pdfParams.y -= 15;
            PDPixelMap titleImage = new PDPixelMap(pdfParams.getDocument(),
                    ImageIO.read(getFileStreamFromResources("images/pdf/error.png")));
            pdfParams.getContentStream().drawXObject(titleImage, pos_x + 5, pdfParams.y - 1, 9, 9);
            pdfParams = writeText(pdfParams, row, pos_x + margins[1], font, font_size);
        }

        /**
         * Conformance checkers
         */
        pdfParams.y -= 40;
        font_size = 10;
        pdfParams = writeTitle(pdfParams, "Conformance checkers", "images/pdf/thumbs.png", pos_x, font,
                font_size);
        for (String iso : ir.getIsosCheck()) {
            if (ir.hasValidation(iso)) {
                String name = ImplementationCheckerLoader.getIsoName(iso);
                pdfParams = writeErrorsWarnings(pdfParams, font, ir.getErrors(iso), ir.getOnlyWarnings(iso),
                        ir.getOnlyInfos(iso), pos_x, name, iso.equals(TiffConformanceChecker.POLICY_ISO));
            }
        }

        pdfParams.getContentStream().close();

        ir.setPDF(pdfParams.getDocument());
    } catch (Exception tfe) {
        tfe.printStackTrace();
        ir.setPDF(null);
        //context.send(BasicConfig.MODULE_MESSAGE, new ExceptionMessage("Exception in ReportPDF", tfe));
    }
}

From source file:net.sf.jasperreports.chartthemes.simple.SimpleSettingsFactory.java

/**
 *
 *//*ww w  . j  a v  a  2s.c o  m*/
public static final ChartThemeSettings createChartThemeSettings() {
    ChartThemeSettings settings = new ChartThemeSettings();

    ChartSettings chartSettings = settings.getChartSettings();
    chartSettings.setBackgroundPaint(new GradientPaintProvider(Color.green, Color.blue));
    chartSettings.setBackgroundImage(
            new FileImageProvider("net/sf/jasperreports/chartthemes/simple/jasperreports.png"));
    chartSettings.setBackgroundImageAlignment(Align.TOP_RIGHT);
    chartSettings.setBackgroundImageAlpha(1f);
    chartSettings.setBorderVisible(Boolean.TRUE);
    chartSettings.setBorderPaint(new ColorProvider(Color.GREEN));
    chartSettings.setBorderStroke(new BasicStroke(1f));
    chartSettings.setAntiAlias(Boolean.TRUE);
    chartSettings.setTextAntiAlias(Boolean.TRUE);
    chartSettings.setPadding(new RectangleInsets(UnitType.ABSOLUTE, 1.1, 2.2, 3.3, 4.4));

    TitleSettings titleSettings = settings.getTitleSettings();
    titleSettings.setShowTitle(Boolean.TRUE);
    titleSettings.setPosition(EdgeEnum.TOP);
    titleSettings.setForegroundPaint(new ColorProvider(Color.black));
    titleSettings.setBackgroundPaint(new GradientPaintProvider(Color.green, Color.blue));
    titleSettings.getFont().setBold(Boolean.TRUE);
    titleSettings.getFont().setFontSize(22f);
    titleSettings.setHorizontalAlignment(HorizontalAlignment.CENTER);
    titleSettings.setVerticalAlignment(VerticalAlignment.TOP);
    titleSettings.setPadding(new RectangleInsets(UnitType.ABSOLUTE, 1.1, 2.2, 3.3, 4.4));

    TitleSettings subtitleSettings = settings.getSubtitleSettings();
    subtitleSettings.setShowTitle(Boolean.TRUE);
    subtitleSettings.setPosition(EdgeEnum.TOP);
    subtitleSettings.setForegroundPaint(new ColorProvider(Color.red));
    subtitleSettings.setBackgroundPaint(new GradientPaintProvider(Color.green, Color.blue));
    subtitleSettings.getFont().setBold(Boolean.TRUE);
    subtitleSettings.setHorizontalAlignment(HorizontalAlignment.LEFT);
    subtitleSettings.setVerticalAlignment(VerticalAlignment.CENTER);
    subtitleSettings.setPadding(new RectangleInsets(UnitType.ABSOLUTE, 1.1, 2.2, 3.3, 4.4));

    LegendSettings legendSettings = settings.getLegendSettings();
    legendSettings.setShowLegend(Boolean.TRUE);
    legendSettings.setPosition(EdgeEnum.BOTTOM);
    legendSettings.setForegroundPaint(new ColorProvider(Color.black));
    legendSettings.setBackgroundPaint(new GradientPaintProvider(Color.green, Color.blue));
    legendSettings.getFont().setBold(Boolean.TRUE);
    legendSettings.setHorizontalAlignment(HorizontalAlignment.CENTER);
    legendSettings.setVerticalAlignment(VerticalAlignment.BOTTOM);
    //FIXMETHEME legendSettings.setBlockFrame();
    legendSettings.setPadding(new RectangleInsets(UnitType.ABSOLUTE, 1.1, 2.2, 3.3, 4.4));

    PlotSettings plotSettings = settings.getPlotSettings();
    plotSettings.setOrientation(PlotOrientation.VERTICAL);
    //      plotSettings.setForegroundAlpha(0.5f);
    plotSettings.setBackgroundPaint(new GradientPaintProvider(Color.green, Color.blue));
    //      plotSettings.setBackgroundAlpha(0.5f);
    plotSettings.setBackgroundImage(
            new FileImageProvider("net/sf/jasperreports/chartthemes/simple/jasperreports.png"));
    plotSettings.setBackgroundImageAlpha(0.5f);
    plotSettings.setBackgroundImageAlignment(Align.NORTH_WEST);
    plotSettings.setLabelRotation(0d);
    plotSettings.setPadding(new RectangleInsets(UnitType.ABSOLUTE, 1.1, 2.2, 3.3, 4.4));
    plotSettings.setOutlineVisible(Boolean.TRUE);
    plotSettings.setOutlinePaint(new ColorProvider(Color.red));
    plotSettings.setOutlineStroke(new BasicStroke(1f));
    plotSettings.setSeriesColorSequence(COLORS);
    //      plotSettings.setSeriesGradientPaintSequence(GRADIENT_PAINTS);
    plotSettings.setSeriesOutlinePaintSequence(COLORS_DARKER);
    plotSettings.setSeriesStrokeSequence(STROKES);
    plotSettings.setSeriesOutlineStrokeSequence(OUTLINE_STROKES);
    plotSettings.setDomainGridlineVisible(Boolean.TRUE);
    plotSettings.setDomainGridlinePaint(new ColorProvider(Color.DARK_GRAY));
    plotSettings.setDomainGridlineStroke(new BasicStroke(0.5f));
    plotSettings.setRangeGridlineVisible(Boolean.TRUE);
    plotSettings.setRangeGridlinePaint(new ColorProvider(Color.BLACK));
    plotSettings.setRangeGridlineStroke(new BasicStroke(0.5f));
    plotSettings.getTickLabelFont().setFontName("Courier");
    plotSettings.getTickLabelFont().setBold(Boolean.TRUE);
    plotSettings.getTickLabelFont().setFontSize(10f);
    plotSettings.getDisplayFont().setFontName("Arial");
    plotSettings.getDisplayFont().setBold(Boolean.TRUE);
    plotSettings.getDisplayFont().setFontSize(12f);

    AxisSettings domainAxisSettings = settings.getDomainAxisSettings();
    domainAxisSettings.setVisible(Boolean.TRUE);
    domainAxisSettings.setLocation(AxisLocation.BOTTOM_OR_RIGHT);
    domainAxisSettings.setLinePaint(new ColorProvider(Color.green));
    domainAxisSettings.setLineStroke(new BasicStroke(1f));
    domainAxisSettings.setLineVisible(Boolean.TRUE);
    //      domainAxisSettings.setLabel("Domain Axis");
    domainAxisSettings.setLabelAngle(0.0d);
    domainAxisSettings.setLabelPaint(new ColorProvider(Color.magenta));
    domainAxisSettings.getLabelFont().setBold(Boolean.TRUE);
    domainAxisSettings.getLabelFont().setItalic(Boolean.TRUE);
    domainAxisSettings.getLabelFont().setFontName("Comic Sans MS");
    domainAxisSettings.getLabelFont().setFontSize(12f);
    domainAxisSettings.setLabelInsets(new RectangleInsets(UnitType.ABSOLUTE, 0.5, 0.5, 1, 1));
    domainAxisSettings.setLabelVisible(Boolean.TRUE);
    domainAxisSettings.setTickLabelPaint(new ColorProvider(Color.cyan));
    domainAxisSettings.getTickLabelFont().setBold(Boolean.TRUE);
    domainAxisSettings.getTickLabelFont().setItalic(Boolean.FALSE);
    domainAxisSettings.getTickLabelFont().setFontName("Arial");
    domainAxisSettings.getTickLabelFont().setFontSize(10f);
    domainAxisSettings.setTickLabelInsets(new RectangleInsets(UnitType.ABSOLUTE, 0.5, 0.5, 0.5, 0.5));
    domainAxisSettings.setTickLabelsVisible(Boolean.TRUE);
    domainAxisSettings.setTickMarksInsideLength(0.1f);
    domainAxisSettings.setTickMarksOutsideLength(0.2f);
    domainAxisSettings.setTickMarksPaint(new ColorProvider(Color.ORANGE));
    domainAxisSettings.setTickMarksStroke(new BasicStroke(1f));
    domainAxisSettings.setTickMarksVisible(Boolean.TRUE);
    domainAxisSettings.setTickCount(5);

    AxisSettings rangeAxisSettings = settings.getRangeAxisSettings();
    rangeAxisSettings.setVisible(Boolean.TRUE);
    rangeAxisSettings.setLocation(AxisLocation.TOP_OR_RIGHT);
    rangeAxisSettings.setLinePaint(new ColorProvider(Color.yellow));
    rangeAxisSettings.setLineStroke(new BasicStroke(1f));
    rangeAxisSettings.setLineVisible(Boolean.TRUE);
    //      rangeAxisSettings.setLabel("Range Axis");
    rangeAxisSettings.setLabelAngle(Math.PI / 2.0d);
    rangeAxisSettings.setLabelPaint(new ColorProvider(Color.green));
    rangeAxisSettings.getLabelFont().setBold(Boolean.TRUE);
    rangeAxisSettings.getLabelFont().setItalic(Boolean.TRUE);
    rangeAxisSettings.getLabelFont().setFontName("Comic Sans MS");
    rangeAxisSettings.getLabelFont().setFontSize(12f);
    rangeAxisSettings.setLabelInsets(new RectangleInsets(UnitType.ABSOLUTE, 0.5, 0.5, 1, 1));
    rangeAxisSettings.setLabelVisible(Boolean.TRUE);
    rangeAxisSettings.setTickLabelPaint(new ColorProvider(Color.pink));
    rangeAxisSettings.getTickLabelFont().setBold(Boolean.FALSE);
    rangeAxisSettings.getTickLabelFont().setItalic(Boolean.TRUE);
    rangeAxisSettings.getTickLabelFont().setFontName("Arial");
    rangeAxisSettings.getTickLabelFont().setFontSize(10f);
    rangeAxisSettings.setTickLabelInsets(new RectangleInsets(UnitType.ABSOLUTE, 0.5, 0.5, 0.5, 0.5));
    rangeAxisSettings.setTickLabelsVisible(Boolean.TRUE);
    rangeAxisSettings.setTickMarksInsideLength(0.2f);
    rangeAxisSettings.setTickMarksOutsideLength(0.1f);
    rangeAxisSettings.setTickMarksPaint(new ColorProvider(Color.black));
    rangeAxisSettings.setTickMarksStroke(new BasicStroke(1f));
    rangeAxisSettings.setTickMarksVisible(Boolean.TRUE);
    rangeAxisSettings.setTickCount(6);

    return settings;
}

From source file:edu.umn.cs.spatialHadoop.OperationsParams.java

public static Color getColor(Configuration conf, String key, Color defaultValue) {
    String colorName = conf.get(key);
    if (colorName == null)
        return defaultValue;

    colorName = colorName.toLowerCase();
    Color color = defaultValue;/*ww w .  j  av  a 2s. c o m*/
    if (colorName.equals("red")) {
        color = Color.RED;
    } else if (colorName.equals("pink")) {
        color = Color.PINK;
    } else if (colorName.equals("blue")) {
        color = Color.BLUE;
    } else if (colorName.equals("cyan")) {
        color = Color.CYAN;
    } else if (colorName.equals("green")) {
        color = Color.GREEN;
    } else if (colorName.equals("black")) {
        color = Color.BLACK;
    } else if (colorName.equals("white")) {
        color = Color.WHITE;
    } else if (colorName.equals("gray")) {
        color = Color.GRAY;
    } else if (colorName.equals("yellow")) {
        color = Color.YELLOW;
    } else if (colorName.equals("orange")) {
        color = Color.ORANGE;
    } else if (colorName.equals("none")) {
        color = new Color(0, 0, 255, 0);
    } else if (colorName.matches("#[a-zA-Z0-9]{8}")) {
        String redHex = colorName.substring(1, 2);
        String greenHex = colorName.substring(3, 4);
        String blueHex = colorName.substring(5, 6);
        String opacityHex = colorName.substring(7, 8);
        int red = Integer.parseInt(redHex, 16);
        int green = Integer.parseInt(greenHex, 16);
        int blue = Integer.parseInt(blueHex, 16);
        int opacity = Integer.parseInt(opacityHex, 16);
        color = new Color(red, green, blue, opacity);
    } else {
        LOG.warn("Does not understand the color '" + conf.get(key) + "'");
    }

    return color;
}

From source file:convcao.com.agent.ConvcaoNeptusInteraction.java

@Override
public void paint(Graphics2D g2, StateRenderer2D renderer) {
    Graphics2D g = (Graphics2D) g2.create();

    Point2D center = renderer.getScreenPosition(coords.squareCenter);
    double width = renderer.getZoom() * coords.cellWidth * coords.numCols;
    double height = renderer.getZoom() * coords.cellWidth * coords.numRows;
    g.setColor(new Color(0, 0, 255, 64));
    g.translate(center.getX(), center.getY());
    g.rotate(-renderer.getRotation());//  w w w . jav  a2 s .  c om
    g.fill(new Rectangle2D.Double(-width / 2, -height / 2, width, height));
    g.rotate(renderer.getRotation());
    g.translate(-center.getX(), -center.getY());

    if (!active) {
        g.dispose();
        return;
    }

    g.setColor(Color.orange);
    int pos = 50;
    for (String v : nameTable.values()) {
        g.drawString(v + ": " + depths.get(v) + "m", 15, pos);
        pos += 20;
    }

    for (String vehicle : nameTable.values()) {
        LocationType src = positions.get(vehicle);
        LocationType dst = destinations.get(vehicle);

        if (!arrived.get(vehicle))
            g.setColor(Color.red.darker());
        else
            g.setColor(Color.green.darker());
        float dash[] = { 4.0f };
        g.setStroke(new BasicStroke(1.0f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER, 5.0f, dash, 0.0f));
        g.draw(new Line2D.Double(renderer.getScreenPosition(src), renderer.getScreenPosition(dst)));

        Point2D dstPt = renderer.getScreenPosition(dst);

        if (!arrived.get(vehicle))
            g.setColor(Color.red.darker());
        else
            g.setColor(Color.green.darker());

        g.fill(new Ellipse2D.Double(dstPt.getX() - 4, dstPt.getY() - 4, 8, 8));
    }

    g.dispose();
}

From source file:de.codesourcery.eve.skills.ui.renderer.SkillTreeRenderer.java

private Color getColorForSkill(Prerequisite r, ICharacter character) {

    final Skill s = r.getSkill();
    if (character == null) {
        return Color.RED;
    }//from   www .jav  a 2 s.c  o m

    if (character.hasSkill(s, r.getRequiredLevel())) {
        return GREEN;
    } else if (character.canTrainSkill(s) || character.hasSkill(s)) {
        return Color.ORANGE;
    }
    return Color.RED;
}

From source file:at.tuwien.ifs.somtoolbox.apps.viewer.GeneralUnitPNode.java

/**
 * Initializes common properties for unit PNodes and empty PNodes
 *//*ww  w .j  a v a  2s.  co m*/
private void initPNodeProperties(double width, double height) {
    border = new Rectangle2D.Double();
    GridGeometry helper = state.growingLayer.getGridGeometry();
    this.width = helper.adjustUnitWidth(width, height);
    this.height = helper.adjustUnitHeight(width, height);
    border.setRect(X, Y, width, height);
    this.setBounds(X, Y, width, height);
    selectionMarker = PPath.createRectangle((float) X, (float) Y, (float) width, (float) height);
    selectionMarker.setPaint(Color.decode("#ff7505"));
    selectionMarker.setTransparency(0.5f);

    queryResultMarker = PPath.createRectangle((float) X, (float) Y, (float) width, (float) height);
    queryResultMarker.setPaint(Color.ORANGE);
    queryResultMarker.setTransparency(0.5f);
}