Example usage for java.awt Color LIGHT_GRAY

List of usage examples for java.awt Color LIGHT_GRAY

Introduction

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

Prototype

Color LIGHT_GRAY

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

Click Source Link

Document

The color light gray.

Usage

From source file:uk.ac.ncl.aries.entanglement.cli.export.MongoGraphToGDF.java

private static Map<String, Color> loadColorMappings(File propFile) throws IOException {
    FileInputStream is = new FileInputStream(propFile);
    Properties props = new Properties();
    props.load(is);//from   ww  w.j a  va2  s.c  o  m
    is.close();

    Map<String, Color> nodeTypeToColour = new HashMap<>();
    for (String nodeType : props.stringPropertyNames()) {
        String colorString = props.getProperty(nodeType);
        Color color;

        switch (colorString) {
        case "BLACK":
            color = Color.BLACK;
            break;
        case "BLUE":
            color = Color.BLUE;
            break;
        case "CYAN":
            color = Color.CYAN;
            break;
        case "DARK_GRAY":
            color = Color.DARK_GRAY;
            break;
        case "GRAY":
            color = Color.GRAY;
            break;
        case "GREEN":
            color = Color.GREEN;
            break;
        case "LIGHT_GRAY":
            color = Color.LIGHT_GRAY;
            break;
        case "MAGENTA":
            color = Color.MAGENTA;
            break;
        case "ORANGE":
            color = Color.ORANGE;
            break;
        case "PINK":
            color = Color.PINK;
            break;
        case "RED":
            color = Color.RED;
            break;
        case "WHITE":
            color = Color.WHITE;
            break;
        case "YELLOW":
            color = Color.YELLOW;
            break;
        default:
            color = DEFAULT_COLOR;
        }

        nodeTypeToColour.put(nodeType, color);
    }
    return nodeTypeToColour;
}

From source file:com.itemanalysis.jmetrik.swing.GraphPanel.java

public void setLineChart(String title, String subtitle, String xlabel, String ylabel) {
    XYSeriesCollection dataset = new XYSeriesCollection();

    chart = ChartFactory.createXYLineChart(title, // chart title
            xlabel, // x axis label
            ylabel, // y axis label
            dataset, // data
            chartOrientation, showLegend, // include legend
            true, // tooltips
            false // urls
    );/*from  w ww .j  a va 2 s . com*/

    if (showLegend) {
        LegendTitle chartTitle = chart.getLegend();
        chartTitle.setPosition(legendPosition);
    }

    if (subtitle != null && !"".equals(subtitle)) {
        TextTitle subtitle1 = new TextTitle(subtitle);
        chart.addSubtitle(subtitle1);
    }

    XYPlot plot = (XYPlot) chart.getPlot();
    plot.setBackgroundPaint(Color.WHITE);
    plot.setRangeGridlinePaint(Color.LIGHT_GRAY);
    plot.setDomainGridlinePaint(Color.LIGHT_GRAY);

    //can use this code to modify charts for book. DO NOT USE FOR NORMAL FUNCTIONING
    //        NumberAxis yaxis = (NumberAxis)plot.getRangeAxis();
    //        yaxis.setTickUnit(new NumberTickUnit(.1));

    ChartPanel panel = new ChartPanel(chart);
    panel.getPopupMenu().addSeparator();
    this.addJpgMenuItem(this, panel.getPopupMenu());
    //        this.addEPSMenuItem(this, panel.getPopupMenu());//remove this line for public release versions
    panel.setPreferredSize(new Dimension(width, height));

    chart.setPadding(new RectangleInsets(20.0, 5.0, 20.0, 5.0));
    this.setBackground(Color.WHITE);
    this.add(panel);

}

From source file:web.diva.server.unused.PCAGenerator.java

public PCAImageResult generateChart(String path, PCAResults pcaResults, int[] subSelectionData, int[] selection,
        boolean zoom, boolean selectAll, String imgName, double w, double h, DivaDataset divaDataset) {
    XYDataset dataset = this.createDataset(pcaResults.getPoints(), subSelectionData, selection, zoom,
            divaDataset);//from   www  .j  ava 2 s  .com
    final JFreeChart chart = ChartFactory.createScatterPlot("", // chart title
            "Principal Component" + (pcaResults.getPcai() + 1), // x axis label
            "Principal Component " + (pcaResults.getPcaii() + 1), // y axis label
            dataset, // data
            PlotOrientation.VERTICAL, false, // include legend
            true, // tooltips
            false // urls
    );
    final XYPlot plot = chart.getXYPlot();
    plot.setBackgroundPaint(Color.WHITE);
    plot.setDomainGridlinePaint(Color.WHITE);
    plot.setRangeGridlinePaint(Color.WHITE);
    XYDotRenderer renderer = new XYDotRenderer();
    renderer.setDotHeight(5);
    renderer.setDotWidth(5);

    if (selectAll) {
        int i = 0;
        for (String col : seriesList.keySet()) {
            if (col.equalsIgnoreCase("unGrouped")) {
                col = "#000000";
            }
            renderer.setSeriesPaint(i, imgGenerator.hex2Rgb(col));
            i++;
        }

    } else if (selection == null) {
        renderer.setPaint(Color.LIGHT_GRAY);
        int i = 0;
        for (String col : seriesList.keySet()) {
            if (col.equalsIgnoreCase("unGrouped")) {
                col = "#000000";
            }
            renderer.setSeriesPaint(i, imgGenerator.hex2Rgb(col));
            i++;
        }
    } else {
        int i = 0;
        for (String col : seriesList.keySet()) {
            if (col.equalsIgnoreCase("unGrouped")) {
                renderer.setSeriesPaint(i, Color.LIGHT_GRAY);
            } else {
                renderer.setSeriesPaint(i, imgGenerator.hex2Rgb(col));

            }
            i++;
        }
    }
    plot.setRenderer(renderer);
    plot.setSeriesRenderingOrder(SeriesRenderingOrder.REVERSE);
    NumberAxis xAxis = new NumberAxis("Principal Component" + (pcaResults.getPcai() + 1));
    xAxis.setVerticalTickLabels(true);
    boolean auto = xAxis.getAutoRangeIncludesZero();
    xAxis.setAutoRangeIncludesZero(true ^ auto);
    NumberAxis yAxis = new NumberAxis("Principal Component" + (pcaResults.getPcaii() + 1));
    yAxis.setAutoRangeIncludesZero(true ^ auto);
    yAxis.setTickUnit(new NumberTickUnit(1));
    plot.setDomainAxis(0, xAxis);
    plot.setRangeAxis(0, yAxis);

    double MaxX = xAxis.getRange().getUpperBound();
    double MinX = xAxis.getRange().getLowerBound();
    double MaxY = yAxis.getRange().getUpperBound();
    double MinY = yAxis.getRange().getLowerBound();

    chartRenderingInfo.clear();
    String imgUrl = imgGenerator.saveToFile(chart, w, h, chartRenderingInfo);
    PCAImageResult imgUtilRes = new PCAImageResult();
    imgUtilRes.setImgString(imgUrl);
    imgUtilRes.setDataAreaMaxX(chartRenderingInfo.getPlotInfo().getDataArea().getMaxX());
    imgUtilRes.setDataAreaMaxY(chartRenderingInfo.getPlotInfo().getDataArea().getMaxY());
    imgUtilRes.setDataAreaMinY(chartRenderingInfo.getPlotInfo().getDataArea().getMinY());
    imgUtilRes.setDataAreaMinX(chartRenderingInfo.getPlotInfo().getDataArea().getMinX());
    imgUtilRes.setMaxX(MaxX);
    imgUtilRes.setMaxY(MaxY);
    imgUtilRes.setMinX(MinX);
    imgUtilRes.setMinY(MinY);
    return imgUtilRes;
}

From source file:org.datavyu.controllers.component.TrackController.java

/**
 * Creates a new TrackController.//  ww  w.ja va  2 s. c o  m
 *
 * @param trackPainter the track painter for this controller to manage.
 */
public TrackController(final MixerModel mixerModel, final TrackPainter trackPainter) {
    isMoveable = true;

    view = new JPanel();
    view.setLayout(new MigLayout("fillx, ins 0", "[]0[]"));
    view.setBorder(BorderFactory.createLineBorder(TrackConstants.BORDER_COLOR, 1));

    this.trackPainter = trackPainter;

    this.mixerModel = mixerModel;
    trackModel = new TrackModel();
    trackModel.setState(TrackState.NORMAL);
    trackModel.clearBookmarks();
    trackModel.setLocked(false);

    trackPainter.setMixerView(mixerModel);
    trackPainter.setTrackModel(trackModel);

    mixerModel.getViewportModel().addPropertyChangeListener(this);

    listenerList = new EventListenerList();

    final TrackPainterListener painterListener = new TrackPainterListener();
    trackPainter.addMouseListener(painterListener);
    trackPainter.addMouseMotionListener(painterListener);

    menu = new JPopupMenu();
    menu.setName("trackPopUpMenu");

    setBookmarkMenuItem = new JMenuItem("Set bookmark");
    setBookmarkMenuItem.addActionListener(new ActionListener() {
        public void actionPerformed(final ActionEvent e) {
            TrackController.this.setBookmarkAction();
        }
    });

    clearBookmarkMenuItem = new JMenuItem("Clear bookmarks");
    clearBookmarkMenuItem.addActionListener(new ActionListener() {
        public void actionPerformed(final ActionEvent e) {
            TrackController.this.clearBookmarkAction();
        }
    });
    menu.add(setBookmarkMenuItem);
    menu.add(clearBookmarkMenuItem);

    trackPainter.add(menu);

    // Create the Header panel and its components
    trackLabel = new JLabel("", SwingConstants.CENTER);
    trackLabel.setName("trackLabel");
    trackLabel.setHorizontalAlignment(SwingConstants.CENTER);
    trackLabel.setHorizontalTextPosition(SwingConstants.CENTER);
    iconLabel = new JLabel("", SwingConstants.CENTER);
    iconLabel.setHorizontalAlignment(SwingConstants.CENTER);
    iconLabel.setHorizontalTextPosition(SwingConstants.CENTER);

    header = new JPanel(new MigLayout("ins 0, wrap 6"));
    header.setBorder(BorderFactory.createCompoundBorder(
            BorderFactory.createMatteBorder(0, 0, 0, 1, TrackConstants.BORDER_COLOR),
            BorderFactory.createEmptyBorder(2, 2, 2, 2)));
    header.setBackground(Color.LIGHT_GRAY);

    // Normally I would use pushx instead of defining the width, but in this
    // case I defined the width because span combined with push makes the
    // first action icon cell push out as well. 136 was calculated from
    // 140 pixels minus 2 minus 2 (from the empty border defined above).
    header.add(trackLabel, "span 6, w 136!, center, growx");
    header.add(iconLabel, "span 6, w 136!, h 32!, center, growx");

    // Set up the button used for locking/unlocking track movement
    {
        lockUnlockButton = new JButton(TrackConstants.UNLOCK_ICON);
        lockUnlockButton.setName("lockUnlockButton");
        lockUnlockButton.setContentAreaFilled(false);
        lockUnlockButton.setBorderPainted(false);
        lockUnlockButton.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(final ActionEvent e) {
                handleLockUnlockButtonEvent(e);
            }
        });

        Map<String, String> constraints = Maps.newHashMap();
        constraints.put("width", Integer.toString(TrackConstants.ACTION_BUTTON_WIDTH));
        constraints.put("height", Integer.toString(TrackConstants.ACTION_BUTTON_HEIGHT));

        String template = "cell 0 2, w ${width}!, h ${height}!";
        StrSubstitutor sub = new StrSubstitutor(constraints);

        header.add(lockUnlockButton, sub.replace(template));
    }

    // Set up the button used for hiding/showing a track's data viewer
    {
        visibleButton = new JButton(TrackConstants.VIEWER_HIDE_ICON);
        visibleButton.setName("visibleButton");
        visibleButton.setContentAreaFilled(false);
        visibleButton.setBorderPainted(false);
        visibleButton.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(final ActionEvent e) {
                handleVisibleButtonEvent(e);
            }
        });

        Map<String, String> constraints = Maps.newHashMap();
        constraints.put("width", Integer.toString(TrackConstants.ACTION_BUTTON_WIDTH));
        constraints.put("height", Integer.toString(TrackConstants.ACTION_BUTTON_HEIGHT));

        String template = "cell 1 2, w ${width}!, h ${height}!";
        StrSubstitutor sub = new StrSubstitutor(constraints);

        header.add(visibleButton, sub.replace(template));
    }

    // Set up the button used for removing a track and its plugin
    {
        rubbishButton = new JButton(TrackConstants.DELETE_ICON);
        rubbishButton.setName("rubbishButton");
        rubbishButton.setContentAreaFilled(false);
        rubbishButton.setBorderPainted(false);
        rubbishButton.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(final ActionEvent e) {
                handleDeleteButtonEvent(e);
            }
        });

        Map<String, String> constraints = Maps.newHashMap();
        constraints.put("width", Integer.toString(TrackConstants.ACTION_BUTTON_WIDTH));
        constraints.put("height", Integer.toString(TrackConstants.ACTION_BUTTON_HEIGHT));

        String template = "cell 5 2, w ${width}!, h ${height}!";
        StrSubstitutor sub = new StrSubstitutor(constraints);

        header.add(rubbishButton, sub.replace(template));
    }

    // Add the header to our layout.
    {
        Map<String, String> constraints = Maps.newHashMap();
        constraints.put("width", Integer.toString(TrackConstants.HEADER_WIDTH));
        constraints.put("height", Integer.toString(TrackConstants.CARRIAGE_HEIGHT));

        String template = "w ${width}!, h ${height}!";
        StrSubstitutor sub = new StrSubstitutor(constraints);

        view.add(header, sub.replace(template));
    }

    // Add the track carriage to our layout.
    {
        Map<String, String> constraints = Maps.newHashMap();
        constraints.put("height", Integer.toString(TrackConstants.CARRIAGE_HEIGHT));

        String template = "pushx, growx, h ${height}!";
        StrSubstitutor sub = new StrSubstitutor(constraints);

        view.add(trackPainter, sub.replace(template));
    }

    view.validate();
}

From source file:no.uio.medicine.virsurveillance.charts.StackedChart_AWT.java

private Color getColor(int index) {
    int index2 = index + this.colorOffset;
    switch (index2) {
    case 0://w  w w. j a va  2  s. c o  m
        return Color.RED;
    case 1:
        return Color.BLUE;
    case 2:
        return Color.GREEN;
    case 3:
        return Color.YELLOW;
    case 4:
        return Color.DARK_GRAY;
    case 5:
        return Color.ORANGE;
    case 6:
        return Color.BLACK;
    case 7:
        return Color.CYAN;
    case 8:
        return Color.GRAY;
    case 9:
        return Color.LIGHT_GRAY;
    case 10:
        return Color.MAGENTA;
    case 11:
        return Color.PINK;
    case 12:
        return Color.WHITE;
    default:
        return getColor((int) Math.floor(Math.random() * 14));
    }

}

From source file:org.squidy.designer.zoom.impl.PortShape.java

public PortShape() {
    setBounds(Constants.DEFAULT_PORT_BOUNDS);

    addInputEventListener(new PBasicInputEventHandler() {

        /*//from   w  w w  .j a v a2 s. c  om
         * (non-Javadoc)
         * 
         * @see
         * edu.umd.cs.piccolo.event.PBasicInputEventHandler#mousePressed
         * (edu.umd.cs.piccolo .event.PInputEvent)
         */
        @Override
        public void mousePressed(PInputEvent event) {
            super.mousePressed(event);

            if (!event.isHandled()) {
                isCreatingEdge = true;
                Rectangle2D bounds = localToGlobal(getBounds());
                startX = bounds.getX() + bounds.getWidth() / 2;// .getCenterX();
                startY = bounds.getY() + bounds.getWidth() / 2;// .getCenterY();
                currentX = startX;
                currentY = startY;

                // moveToFront();

                event.setHandled(true);
            }
        }

        /*
         * (non-Javadoc)
         * 
         * @see
         * edu.umd.cs.piccolo.event.PBasicInputEventHandler#mouseReleased
         * (edu.umd.cs.piccolo.event.PInputEvent)
         */
        @Override
        public void mouseReleased(PInputEvent event) {
            super.mouseReleased(event);

            isCreatingEdge = false;

            ConnectionManager connectionManager = ShapeUtils.getConnectionManager(PortShape.this);

            Point2D point = event.getPosition();

            if (connectionManager.hasConnectionAtDifferentNodeAtPoint(PortShape.this, point)) {
                if (LOG.isDebugEnabled()) {
                    LOG.debug("Connection port found at " + point);
                }

                ConnectorShape<?, ?> source = (ConnectorShape<?, ?>) getParent();
                ConnectorShape<?, ?> target = (ConnectorShape<?, ?>) connectionManager
                        .getConnectionAtPoint(point).getParent();

                if (!source.getParent().equals(target.getParent())) {
                    //                  ConnectorShape<?, ?> tmp = source;
                    //                  source = target;
                    //                  target = tmp;
                }

                PipeShape pipeShape;
                try {
                    pipeShape = PipeShape.create(source, target);
                } catch (Exception e) {
                    publishNotification(new TemporaryNotification(e.getMessage()));
                    return;
                }

                VisualShape<VisualShape<?>> parentShape;
                if (!source.getParent().equals(target.getParent())) {
                    if (target.getParent().equals(source)) {
                        parentShape = (VisualShape<VisualShape<?>>) source;
                    } else {
                        parentShape = (VisualShape<VisualShape<?>>) target;
                    }
                } else {
                    parentShape = (VisualShape<VisualShape<?>>) source.getParent();
                }

                parentShape.addVisualShape(pipeShape);
                pipeShape.invalidateFullBounds();
            } else {
                // TODO [RR]: Repaint from bounds (do not repaint full node bounds)
                getParent().getParent().invalidatePaint();
            }
        }

        /*
         * (non-Javadoc)
         * 
         * @see
         * edu.umd.cs.piccolo.event.PBasicInputEventHandler#mouseDragged
         * (edu.umd.cs.piccolo.event.PInputEvent)
         */
        @Override
        public void mouseDragged(PInputEvent event) {
            super.mouseDragged(event);

            Point2D point = event.getPosition();

            currentX = point.getX();
            currentY = point.getY();

            event.getCamera().invalidatePaint();

            event.setHandled(true);
        }

        /*
         * (non-Javadoc)
         * 
         * @see
         * edu.umd.cs.piccolo.event.PBasicInputEventHandler#mouseEntered
         * (edu.umd.cs.piccolo.event.PInputEvent)
         */
        @Override
        public void mouseEntered(PInputEvent event) {
            super.mouseEntered(event);

            innerColor = Color.GRAY;
        }

        /*
         * (non-Javadoc)
         * 
         * @see
         * edu.umd.cs.piccolo.event.PBasicInputEventHandler#mouseExited(
         * edu.umd.cs.piccolo.event.PInputEvent)
         */
        @Override
        public void mouseExited(PInputEvent event) {
            super.mouseExited(event);

            innerColor = Color.LIGHT_GRAY;
        }
    });
}

From source file:es.emergya.ui.gis.layers.MapViewerLayer.java

@Override
public void paint(Graphics g, MapView mv) {
    parent = (CustomMapView) mv;//from w  w w .  j a  va 2  s . co m

    int iMove = 0;

    zoom = mv.zoom();
    LatLon cen = Main.proj.eastNorth2latlon(mv.getCenter());

    center = new Point(OsmMercator.LonToX(cen.getX(), zoom), OsmMercator.LatToY(cen.getY(), zoom));

    int tilex = center.x / Tile.SIZE;
    int tiley = center.y / Tile.SIZE;
    int off_x = (center.x % Tile.SIZE);
    int off_y = (center.y % Tile.SIZE);

    int w2 = mv.getWidth() / 2;
    int h2 = mv.getHeight() / 2;
    int posx = w2 - off_x;
    int posy = h2 - off_y;

    int diff_left = off_x;
    int diff_right = Tile.SIZE - off_x;
    int diff_top = off_y;
    int diff_bottom = Tile.SIZE - off_y;

    boolean start_left = diff_left < diff_right;
    boolean start_top = diff_top < diff_bottom;

    if (start_top) {
        if (start_left) {
            iMove = 2;
        } else {
            iMove = 3;
        }
    } else {
        if (start_left) {
            iMove = 1;
        } else {
            iMove = 0;
        }
    } // calculate the visibility borders
    int x_min = -Tile.SIZE;
    int y_min = -Tile.SIZE;
    int x_max = mv.getWidth();
    int y_max = mv.getHeight();

    // paint the tiles in a spiral, starting from center of the map
    boolean painted = true;
    int x = 0;
    while (painted) {
        painted = false;
        for (int i = 0; i < 4; i++) {
            if (i % 2 == 0) {
                x++;
            }
            for (int j = 0; j < x; j++) {
                if (x_min <= posx && posx <= x_max && y_min <= posy && posy <= y_max) {
                    // tile is visible
                    Tile tile = getTile(tilex, tiley, zoom);
                    if (tile != null) {
                        painted = true;
                        tile.paint(g, posx, posy);
                        if (tileGridVisible) {
                            g.drawString(tile.getXtile() + ", " + tile.getYtile(), posx, posy + 12);
                            g.drawRect(posx, posy, Tile.SIZE, Tile.SIZE);
                        }
                    }
                }
                Point p = move[iMove];
                posx += p.x * Tile.SIZE;
                posy += p.y * Tile.SIZE;
                tilex += p.x;
                tiley += p.y;
            }
            iMove = (iMove + 1) % move.length;
        }
    }
    // outer border of the map
    int mapSize = Tile.SIZE << zoom;
    g.drawRect(w2 - center.x, h2 - center.y, mapSize, mapSize);

    if (LOG.isDebugEnabled()) {
        g.setColor(Color.LIGHT_GRAY);
        g.drawString("Tiles in cache: " + tileCache.getTileCount(), 50, 15);
    }

    // g.fillRect(0, 100, 300, 55);
    // g.setColor(Color.BLACK);
    // g.drawString("center: " + center.x + ", " + center.y, 5, 120);
    // g.drawString("zoom: " + zoom + " for scale:" + mv.getScale(), 5,
    // 150);
}

From source file:com.rapidminer.gui.plotter.charts.ParallelPlotter2.java

@Override
public void updatePlotter() {
    prepareData();//from   w  w  w. j a v a2 s  .c o  m

    JFreeChart chart = createChart(this.dataset);

    // set the background color for the chart...
    chart.setBackgroundPaint(Color.white);

    // general plot settings
    XYPlot plot = chart.getXYPlot();
    plot.setDomainGridlinePaint(Color.LIGHT_GRAY);
    plot.setRangeGridlinePaint(Color.LIGHT_GRAY);

    // domain axis
    SymbolAxis axis = null;
    if (this.dataTable.isSupportingColumnWeights()) {
        List<Double> weightList = new LinkedList<>();
        for (int column = 0; column < dataTable.getNumberOfColumns(); column++) {
            if ((!dataTable.isSpecial(column)) && (column != colorColumn)) {
                weightList.add(this.dataTable.getColumnWeight(column));
            }
        }
        double[] weights = new double[weightList.size()];
        int index = 0;
        for (Double d : weightList) {
            weights[index++] = d;
        }
        axis = new WeightBasedSymbolAxis(null, domainAxisMap, weights);
    } else {
        axis = new SymbolAxis(null, domainAxisMap);
    }
    axis.setTickLabelFont(LABEL_FONT);
    axis.setLabelFont(LABEL_FONT_BOLD);

    // rotate labels
    if (isLabelRotating()) {
        axis.setTickLabelsVisible(true);
        axis.setVerticalTickLabels(true);
    }

    chart.getXYPlot().setDomainAxis(axis);

    // renderer
    final ColorizedLineAndShapeRenderer renderer = new ColorizedLineAndShapeRenderer(this.colorMap);
    plot.setRenderer(renderer);

    // legend settings
    if ((colorColumn >= 0) && (this.dataTable.isNominal(colorColumn))) {
        final LegendItemCollection legendItemCollection = new LegendItemCollection();
        for (int i = 0; i < this.dataTable.getNumberOfValues(colorColumn); i++) {
            legendItemCollection.add(new LegendItem(this.dataTable.mapIndex(colorColumn, i), null, null, null,
                    new Rectangle2D.Double(0, 0, 7, 7),
                    getColorProvider()
                            .getPointColor(i / (double) (this.dataTable.getNumberOfValues(colorColumn) - 1)),
                    new BasicStroke(0.75f), Color.GRAY));
        }
        chart.addLegend(new LegendTitle(new LegendItemSource() {

            @Override
            public LegendItemCollection getLegendItems() {
                return legendItemCollection;
            }
        }));

        LegendTitle legend = chart.getLegend();
        if (legend != null) {
            legend.setPosition(RectangleEdge.TOP);
            legend.setFrame(BlockBorder.NONE);
            legend.setHorizontalAlignment(HorizontalAlignment.LEFT);
            legend.setItemFont(LABEL_FONT);
        }
    } else if (colorColumn >= 0) {
        chart.addLegend(new LegendTitle(new LegendItemSource() {

            @Override
            public LegendItemCollection getLegendItems() {
                LegendItemCollection itemCollection = new LegendItemCollection();
                itemCollection.add(new LegendItem("Dummy"));
                return itemCollection;
            }
        }) {

            private static final long serialVersionUID = 1288380309936848376L;

            @Override
            public Object draw(java.awt.Graphics2D g2, java.awt.geom.Rectangle2D area,
                    java.lang.Object params) {
                if (dataTable.isDate(colorColumn) || dataTable.isTime(colorColumn)
                        || dataTable.isDateTime(colorColumn)) {
                    drawSimpleDateLegend(g2, (int) (area.getCenterX() - 170), (int) (area.getCenterY() + 7),
                            dataTable, colorColumn, renderer.getMinColorValue(), renderer.getMaxColorValue());
                    return new BlockResult();
                } else {
                    final String minColorString = Tools.formatNumber(renderer.getMinColorValue());
                    final String maxColorString = Tools.formatNumber(renderer.getMaxColorValue());
                    drawSimpleNumericalLegend(g2, (int) (area.getCenterX() - 90), (int) (area.getCenterY() + 7),
                            dataTable.getColumnName(colorColumn), minColorString, maxColorString);
                    return new BlockResult();
                }
            }

            @Override
            public void draw(java.awt.Graphics2D g2, java.awt.geom.Rectangle2D area) {
                draw(g2, area, null);
            }

        });
    }

    // chart panel
    if (panel instanceof AbstractChartPanel) {
        panel.setChart(chart);
    } else {
        panel = new AbstractChartPanel(chart, getWidth(), getHeight() - MARGIN);
        final ChartPanelShiftController controller = new ChartPanelShiftController(panel);
        panel.addMouseListener(controller);
        panel.addMouseMotionListener(controller);
    }

    // ATTENTION: WITHOUT THIS WE GET SEVERE MEMORY LEAKS!!!
    panel.getChartRenderingInfo().setEntityCollection(null);
}

From source file:eu.ggnet.dwoss.misc.op.listings.SalesListingProducerOperation.java

@Override
public FileJacket generateAllSalesListing() {
    SubMonitor m = monitorFactory.newSubMonitor("All List", 5);
    m.message("loading Units");
    m.start();// w ww .  ja v  a2 s. co  m

    List<StockUnit> stockUnits = new StockUnitEao(stockEm).findByNoLogicTransaction();
    List<UniqueUnit> uniqueUnits = new UniqueUnitEao(uuEm).findByIds(toUniqueUnitIds(stockUnits));
    m.worked(3, "preparing Units");

    List<Object[]> retailers = new ArrayList<>(stockUnits.size());
    List<Object[]> customers = new ArrayList<>(stockUnits.size());
    for (Map.Entry<UniqueUnit, StockUnit> entry : toSortedMap(uniqueUnits, stockUnits,
            new UniqueUnitComparator()).entrySet()) {
        UniqueUnit uu = entry.getKey();
        StockUnit su = entry.getValue();
        Product p = uu.getProduct();
        Date firstPriced = null;
        for (PriceHistory priceHistory : uu.getPriceHistory()) {
            if (firstPriced == null || firstPriced.after(priceHistory.getDate()))
                firstPriced = priceHistory.getDate();
        }
        String source = "Automatisch";
        if (p != null && p.getFlags().contains(Product.Flag.PRICE_FIXED))
            source = "Manuell (Artikel)";
        else if (uu.getFlags().contains(UniqueUnit.Flag.PRICE_FIXED))
            source = "Manuell (Gert)";
        Object[] row = { uu.getRefurbishId(), (p == null ? null : p.getPartNo()),
                (p == null ? null : p.getGroup().getNote()), (p == null ? null : p.getTradeName().getName()),
                (p == null ? null : p.getName()), (p == null ? null : p.getDescription()),
                uu.getWarranty().getName(), uu.getWarrentyValid(),
                UniqueUnitFormater.toSingleLineAccessories(uu), uu.getCondition().getNote(),
                UniqueUnitFormater.toSingleLineComment(uu), uu.getPrice(PriceType.RETAILER),
                uu.getPrice(PriceType.CUSTOMER),
                (!uu.hasPrice(PriceType.CUSTOMER) ? null
                        : MathUtil.roundedApply(uu.getPrice(PriceType.CUSTOMER), GlobalConfig.TAX, 0)),
                (su.getStock() == null ? su.getTransaction() : su.getStock().getName()), uu.getMfgDate(),
                uu.getInputDate(), firstPriced, source };
        if (uu.getSalesChannel() == SalesChannel.CUSTOMER && uu.hasPrice(PriceType.CUSTOMER))
            customers.add(row);
        else if (uu.getSalesChannel() == SalesChannel.RETAILER
                && (uu.hasPrice(PriceType.CUSTOMER) || uu.hasPrice(PriceType.RETAILER)))
            retailers.add(row);
    }
    m.worked(1,
            "creating File, Endkundengerte: " + customers.size() + ", Hndlergerte: " + retailers.size());

    STable consumerTable = new STable();
    consumerTable
            .setTableFormat(new CFormat(CENTER, TOP, new CBorder(Color.GRAY, CBorder.LineStyle.THIN), true));
    consumerTable.setHeadlineFormat(
            new CFormat(CFormat.FontStyle.BOLD, Color.BLACK, Color.LIGHT_GRAY, CENTER, MIDDLE));
    consumerTable.setRowHeight(1000);
    consumerTable.add(new STableColumn("SopoNr", 12));
    consumerTable.add(new STableColumn("ArtikelNr", 15));
    consumerTable.add(new STableColumn("Warengruppe", 18));
    consumerTable.add(new STableColumn("Hersteller", 15));
    consumerTable.add(new STableColumn("Bezeichnung", 30));
    consumerTable.add(new STableColumn("Beschreibung", 60, LFT));
    consumerTable.add(new STableColumn("Garantie", 18, LFT));
    consumerTable.add(new STableColumn("Garantie bis", 18, new CFormat(Representation.SHORT_DATE)));
    consumerTable.add(new STableColumn("Zubehr", 30, LFT));
    consumerTable.add(new STableColumn("optische Bewertung", 25));
    consumerTable.add(new STableColumn("Bemerkung", 50, LFT));
    consumerTable.add(new STableColumn("Hndler", 15, EURO));
    consumerTable.add(new STableColumn("Endkunde", 15, EURO));
    consumerTable.add(new STableColumn("E.inc.Mwst", 15, EURO));
    consumerTable.add(new STableColumn("Lager", 18));
    consumerTable.add(new STableColumn("Mfg Datum", 18, new CFormat(Representation.SHORT_DATE)));
    consumerTable.add(new STableColumn("Aufnahme Datum", 18, new CFormat(Representation.SHORT_DATE)));
    consumerTable.add(new STableColumn("Erstmalig Bepreist", 18, new CFormat(Representation.SHORT_DATE)));
    consumerTable.add(new STableColumn("Preis Quelle", 18));

    consumerTable.setModel(new STableModelList(customers));

    STable retailerTable = new STable(consumerTable);
    retailerTable.setModel(new STableModelList(retailers));

    CCalcDocument cdoc = new TempCalcDocument();
    cdoc.add(new CSheet("Endkunde", consumerTable));
    cdoc.add(new CSheet("Hndler", retailerTable));
    FileJacket fj = new FileJacket("All", ".xls", LucidCalc.createWriter(LucidCalc.Backend.XLS).write(cdoc));
    m.finish();
    return fj;
}

From source file:com.diversityarrays.kdxplore.trialtool.SimplePlotCellRenderer.java

@Override
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus,
        int row, int column) {
    super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);

    commentMarker = null;/*from  ww w.j  av a 2s  .c  om*/
    sampleIconType = SampleIconType.NORMAL;

    if (value instanceof Plot) {
        Plot plot = (Plot) value;
        if (!plot.isActivated()) {
            sampleIconType = isSelected ? SampleIconType.INACTIVE_PLOT_SELECTED : SampleIconType.INACTIVE_PLOT;
        }
        String str = getHtmlForPlot(plot);
        setText(str);
    }

    if (!isSelected) {
        if ((0 == (row & 1)) == (0 == (column & 1))) {
            // 
            setBackground(Color.LIGHT_GRAY);
        } else {
            // Odd row
            setBackground(Color.WHITE);
        }
    }

    return this;
}