Example usage for java.awt Color decode

List of usage examples for java.awt Color decode

Introduction

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

Prototype

public static Color decode(String nm) throws NumberFormatException 

Source Link

Document

Converts a String to an integer and returns the specified opaque Color .

Usage

From source file:com.opensourcestrategies.activities.reports.ActivitiesChartsService.java

private String createPieChart(DefaultPieDataset dataset, String title)
        throws InfrastructureException, IOException {
    Debug.logInfo("Charting dashboard [" + title + "]", MODULE);
    // set up the chart
    JFreeChart chart = ChartFactory.createPieChart(title, dataset, true, // include legend
            true, // tooltips
            false // urls
    );/*from w  w w  .j av  a2 s  . co  m*/
    chart.setBackgroundPaint(Color.white);
    chart.setBorderVisible(true);
    chart.setPadding(new RectangleInsets(5.0, 5.0, 5.0, 5.0));

    // get a reference to the plot for further customization...
    final PiePlot plot = (PiePlot) chart.getPlot();
    plot.setBackgroundPaint(Color.white);
    plot.setCircular(true);
    plot.setLabelGenerator(new StandardPieSectionLabelGenerator("{0}: {1} / {2}",
            NumberFormat.getNumberInstance(), NumberFormat.getPercentInstance()));
    plot.setNoDataMessage("No data available");

    Color[] colors = {
            Color.decode("#" + infrastructure.getConfigurationValue(
                    OpentapsConfigurationTypeConstants.ACTIVITIES_DASHBOARD_LEADS_NEW_COLOR)),
            Color.decode("#" + infrastructure.getConfigurationValue(
                    OpentapsConfigurationTypeConstants.ACTIVITIES_DASHBOARD_LEADS_OLD_COLOR)),
            Color.decode("#" + infrastructure.getConfigurationValue(
                    OpentapsConfigurationTypeConstants.ACTIVITIES_DASHBOARD_LEADS_NO_ACTIVITY_COLOR)) };
    for (int i = 0; i < dataset.getItemCount(); i++) {
        Comparable<?> key = dataset.getKey(i);
        plot.setSectionPaint(key, colors[i]);
    }

    // save as a png and return the file name
    return ServletUtilities.saveChartAsPNG(chart, chartWidth, chartHeight, null);
}

From source file:es.emergya.ui.gis.popups.RouteDialog.java

private void setRoute(List<Way> ways) {
    clearRoute();//from w ww .ja  va 2  s  .  c  om
    LineElemStyle ls = new LineElemStyle();
    ls.color = Color.decode(LogicConstants.get("WAY_COLOR"));
    ls.width = Integer.parseInt(LogicConstants.get("WAY_WIDTH"));
    for (Way way : ways) {
        route.data.ways.add(way);
        way.mappaintStyle = ls;
    }
    route.visible = true;
    view.addLayer(route, false);
    view.repaint();
}

From source file:com.lfv.lanzius.server.WorkspaceView.java

@Override
protected void paintComponent(Graphics g) {
    int w = getWidth();
    int h = getHeight();

    Document doc = server.getDocument();

    Color storedCol = g.getColor();
    Font storedFont = g.getFont();

    // Fill workspace area
    g.setColor(getBackground());//from   w  w  w  .j a  va  2  s  . c om
    g.fillRect(0, 0, w, h);

    // Should the cached version be updated?
    int updateDocumentVersion = server.getDocumentVersion();
    boolean update = (documentVersion != updateDocumentVersion);

    // Check if we have cached the latest document version, otherwise cache the terminals
    if (update) {
        log.debug("Updating view to version " + updateDocumentVersion);
        terminalMap.clear();
        groupList.clear();
        if (doc != null) {
            synchronized (doc) {

                // Clear the visible attribute on all groups
                // except the started or paused ones
                Element egd = doc.getRootElement().getChild("GroupDefs");
                Iterator iter = egd.getChildren().iterator();
                while (iter.hasNext()) {
                    Element eg = (Element) iter.next();
                    boolean isVisible = !DomTools.getAttributeString(eg, "state", "stopped", false)
                            .equals("stopped");
                    eg.setAttribute("visible", String.valueOf(isVisible));
                }

                // Gather information about terminals and cache it
                Element etd = doc.getRootElement().getChild("TerminalDefs");
                iter = etd.getChildren().iterator();
                while (iter.hasNext()) {
                    Element et = (Element) iter.next();
                    int tid = DomTools.getAttributeInt(et, "id", 0, false);
                    if (tid > 0) {
                        // Create terminal and add it to list
                        Terminal t = new Terminal(tid, DomTools.getAttributeInt(et, "x", 0, false),
                                DomTools.getAttributeInt(et, "y", 0, false),
                                DomTools.getChildText(et, "Name", "T/" + tid, false),
                                DomTools.getAttributeBoolean(et, "online", false, false),
                                DomTools.getAttributeBoolean(et, "selected", false, false));
                        terminalMap.put(tid, t);

                        // Is the terminal monitored?
                        t.isMonitored = DomTools.getAttributeBoolean(et, "monitored", false, false);

                        // Examine the Player element under PlayerSetup
                        t.groupColor = null;
                        Element ep = DomTools.getElementFromSection(doc, "PlayerSetup", "terminalid",
                                String.valueOf(tid));

                        // Has linked player for this terminal
                        if (ep != null) {
                            StringBuffer sb = new StringBuffer();

                            // Append player name
                            sb.append(DomTools.getChildText(ep, "Name", "P/?", true));
                            sb.append(" (");

                            // Append role list
                            boolean hasRoles = false;
                            Element ers = ep.getChild("RoleSetup");
                            if (ers != null) {
                                Iterator iterr = ers.getChildren().iterator();

                                while (iterr.hasNext()) {
                                    Element er = (Element) iterr.next();
                                    String id = er.getAttributeValue("id");
                                    er = DomTools.getElementFromSection(doc, "RoleDefs", "id", id);
                                    if (er != null) {
                                        sb.append(DomTools.getChildText(er, "Name", "R/" + id, false));
                                        sb.append(", ");
                                        hasRoles = true;
                                    }
                                }
                                if (hasRoles) {
                                    // Trim last comma
                                    int len = sb.length();
                                    sb.setLength(Math.max(len - 2, 0));
                                }
                                sb.append(")");
                            }
                            t.roles = sb.toString();

                            // Is the player relocated?
                            t.isRelocated = DomTools.getAttributeBoolean(ep, "relocated", false, false);

                            // Get group name and color
                            Element eg = DomTools.getElementFromSection(doc, "GroupDefs", "id",
                                    DomTools.getAttributeString(ep, "groupid", "0", true));
                            t.groupColor = Color.lightGray;
                            if (eg != null) {
                                String sc = DomTools.getChildText(eg, "Color", null, false);
                                if (sc != null) {
                                    try {
                                        t.groupColor = Color.decode(sc);
                                    } catch (NumberFormatException ex) {
                                        log.warn("Invalid color attribute on Group node, defaulting to grey");
                                    }
                                }
                                //t.name += "  "+DomTools.getChildText(eg, "Name", "G/"+eg.getAttributeValue("id"), false);
                                t.groupName = DomTools.getChildText(eg, "Name",
                                        "G/" + eg.getAttributeValue("id"), false);

                                // This group should now be visible
                                eg.setAttribute("visible", "true");
                            } else
                                log.warn("Invalid groupid attribute on Player node, defaulting to grey");
                        }
                    } else
                        log.error("Invalid id attribute on Terminal node, skipping");
                }

                // Gather information about groups and cache it
                iter = egd.getChildren().iterator();
                while (iter.hasNext()) {
                    Element eg = (Element) iter.next();
                    if (DomTools.getAttributeBoolean(eg, "visible", false, false)) {
                        int gid = DomTools.getAttributeInt(eg, "id", 0, true);
                        if (gid > 0) {
                            Group grp = new Group(gid, DomTools.getChildText(eg, "Name", "G/" + gid, false),
                                    DomTools.getAttributeBoolean(eg, "selected", false, false));
                            groupList.add(grp);

                            // group color
                            String sc = DomTools.getChildText(eg, "Color", null, false);
                            if (sc != null) {
                                try {
                                    grp.color = Color.decode(sc);
                                } catch (NumberFormatException ex) {
                                    log.warn("Invalid color attribute on Group node, defaulting to grey");
                                }
                            }

                            // state color
                            grp.stateColor = Color.red;
                            String state = DomTools.getAttributeString(eg, "state", "stopped", false);
                            if (state.equals("started"))
                                grp.stateColor = Color.green;
                            else if (state.equals("paused"))
                                grp.stateColor = Color.orange;
                        }
                    }
                }
            }
        }
    }

    if (doc == null) {
        g.setColor(Color.black);
        String text = "No configuration loaded. Select 'Load configuration...' from the file menu.";
        g.drawString(text, (w - SwingUtilities.computeStringWidth(g.getFontMetrics(), text)) / 2, h * 5 / 12);
    } else {
        g.setFont(new Font("Dialog", Font.BOLD, 13));

        Iterator<Terminal> itert = terminalMap.values().iterator();
        while (itert.hasNext()) {
            Terminal t = itert.next();

            // Draw box
            int b = t.isSelected ? SERVERVIEW_SELECTION_BORDER : 1;
            g.setColor(Color.black);
            g.fillRect(t.x + SERVERVIEW_SELECTION_BORDER - b, t.y + SERVERVIEW_SELECTION_BORDER - b,
                    SERVERVIEW_TERMINAL_WIDTH + 2 * b, SERVERVIEW_TERMINAL_HEIGHT + 2 * b);
            g.setColor(t.groupColor == null ? Color.white : t.groupColor);
            g.fillRect(t.x + SERVERVIEW_SELECTION_BORDER, t.y + SERVERVIEW_SELECTION_BORDER,
                    SERVERVIEW_TERMINAL_WIDTH, SERVERVIEW_TERMINAL_HEIGHT);

            // Inner areas
            Rectangle r = new Rectangle(t.x + SERVERVIEW_SELECTION_BORDER + SERVERVIEW_TERMINAL_BORDER,
                    t.y + SERVERVIEW_SELECTION_BORDER + SERVERVIEW_TERMINAL_BORDER,
                    SERVERVIEW_TERMINAL_WIDTH - 2 * SERVERVIEW_TERMINAL_BORDER,
                    g.getFontMetrics().getHeight() + 4);

            g.setColor(Color.white);
            g.fillRect(r.x, r.y, r.width, r.height);
            g.fillRect(r.x, r.y + r.height + SERVERVIEW_TERMINAL_BORDER + 2, r.width,
                    SERVERVIEW_TERMINAL_HEIGHT - 3 * SERVERVIEW_TERMINAL_BORDER - r.height - 2);
            g.setColor(Color.black);
            g.drawRect(r.x, r.y, r.width, r.height);
            g.drawRect(r.x, r.y + r.height + SERVERVIEW_TERMINAL_BORDER + 2, r.width,
                    SERVERVIEW_TERMINAL_HEIGHT - 3 * SERVERVIEW_TERMINAL_BORDER - r.height - 2);

            // Name of terminal and group
            if (server.isaClient(t.tid)) {
                g.drawImage(indicatorIsa.getImage(), r.x + r.width - 20, r.y + SERVERVIEW_TERMINAL_HEIGHT - 26,
                        null);
            }
            g.drawString(t.name + " " + t.groupName, r.x + 4, r.y + r.height - 4);

            double px = r.x + 4;
            double py = r.y + r.height + SERVERVIEW_TERMINAL_BORDER + 5;

            // Draw monitored indicator
            if (t.isMonitored) {
                g.drawImage(indicatorMonitored.getImage(), r.x + r.width - 9, r.y + 3, null);
            }

            // Draw relocated indicator
            if (t.isRelocated) {
                g.drawImage(indicatorRelocated.getImage(), r.x + r.width - 9, r.y + 13, null);
            }

            // Draw online indicator
            r.setBounds(r.x, r.y + r.height, r.width, 3);
            g.setColor(t.isOnline ? Color.green : Color.red);
            g.fillRect(r.x, r.y, r.width, r.height);
            g.setColor(Color.black);
            g.drawRect(r.x, r.y, r.width, r.height);

            // Roles
            if (t.roles.length() > 0) {
                LineBreakMeasurer lbm = new LineBreakMeasurer(new AttributedString(t.roles).getIterator(),
                        new FontRenderContext(null, false, true));

                TextLayout layout;
                while ((layout = lbm
                        .nextLayout(SERVERVIEW_TERMINAL_WIDTH - 2 * SERVERVIEW_TERMINAL_BORDER)) != null) {
                    if (py < t.y + SERVERVIEW_TERMINAL_HEIGHT) {
                        py += layout.getAscent();
                        layout.draw((Graphics2D) g, (int) px, (int) py);
                        py += layout.getDescent() + layout.getLeading();
                    }
                }
            }
        }

        // Draw group indicators
        int nbrGroupsInRow = w
                / (2 * Constants.SERVERVIEW_SELECTION_BORDER + 2 + Constants.SERVERVIEW_GROUP_WIDTH);
        if (nbrGroupsInRow < 1)
            nbrGroupsInRow = 1;
        int nbrGroupRows = (groupList.size() + nbrGroupsInRow - 1) / nbrGroupsInRow;

        int innerWidth = Constants.SERVERVIEW_GROUP_WIDTH;
        int innerHeight = g.getFontMetrics().getHeight() + 5;

        int outerWidth = innerWidth + 2 * Constants.SERVERVIEW_SELECTION_BORDER + 2;
        int outerHeight = innerHeight + 2 * Constants.SERVERVIEW_SELECTION_BORDER + 2;

        int x = 0;
        int y = h - outerHeight * nbrGroupRows;

        g.setColor(Color.white);
        g.fillRect(0, y, w, h - y);
        g.setColor(Color.black);
        g.drawLine(0, y - 1, w - 1, y - 1);

        Iterator<Group> iterg = groupList.iterator();
        while (iterg.hasNext()) {
            Group grp = iterg.next();

            // Group box
            grp.boundingRect.setBounds(x, y, outerWidth, outerHeight);
            int b = grp.isSelected ? Constants.SERVERVIEW_SELECTION_BORDER : 1;
            g.setColor(Color.black);
            g.fillRect(x + Constants.SERVERVIEW_SELECTION_BORDER - b + 1,
                    y + Constants.SERVERVIEW_SELECTION_BORDER - b + 1, innerWidth + 2 * b, innerHeight + 2 * b);
            g.setColor(grp.color);
            g.fillRect(x + Constants.SERVERVIEW_SELECTION_BORDER + 1,
                    y + Constants.SERVERVIEW_SELECTION_BORDER + 1, innerWidth, innerHeight);

            g.setColor(Color.black);
            g.drawString(grp.name, x + Constants.SERVERVIEW_SELECTION_BORDER + 4,
                    y + Constants.SERVERVIEW_SELECTION_BORDER + innerHeight - 4 + 1);

            // Draw started indicator
            g.setColor(grp.stateColor);
            g.fillRect(x + Constants.SERVERVIEW_SELECTION_BORDER + 1,
                    y + Constants.SERVERVIEW_SELECTION_BORDER + 1, innerWidth, 2);
            g.setColor(Color.black);
            g.drawLine(x + Constants.SERVERVIEW_SELECTION_BORDER + 1,
                    y + Constants.SERVERVIEW_SELECTION_BORDER + 3,
                    x + Constants.SERVERVIEW_SELECTION_BORDER + 1 + innerWidth,
                    y + Constants.SERVERVIEW_SELECTION_BORDER + 3);

            x += outerWidth;
            if ((x + outerWidth) > w) {
                x = 0;
                y += outerHeight;
            }
        }
    }

    // Store cached version
    documentVersion = updateDocumentVersion;

    g.setColor(storedCol);
    g.setFont(storedFont);
}

From source file:es.emergya.ui.gis.FleetControlMapViewer.java

@Override
protected JPopupMenu getContextMenu() {
    JPopupMenu menu = new JPopupMenu();

    menu.setBackground(Color.decode("#E8EDF6"));

    // Ttulo/*from ww w . j  a  v  a 2s.c  o m*/
    final JMenuItem titulo = new JMenuItem(i18n.getString("map.menu.titulo.puntoGenerico"));
    titulo.setFont(LogicConstants.deriveBoldFont(10.0f));
    titulo.setBackground(Color.decode("#A4A4A4"));
    titulo.setFocusable(false);

    menu.add(titulo);

    menu.addSeparator();

    // Actualizar posicin
    final JMenuItem gps = new JMenuItem(i18n.getString("map.menu.gps"), KeyEvent.VK_P);
    gps.setIcon(LogicConstants.getIcon("menucontextual_icon_actualizargps"));
    menu.add(gps);
    gps.addActionListener(this);
    gps.setEnabled(false);

    menu.addSeparator();

    // Mostrar ms cercanos
    final JMenuItem mmc = new JMenuItem(i18n.getString("map.menu.showNearest"), KeyEvent.VK_M);
    mmc.setIcon(LogicConstants.getIcon("menucontextual_icon_mascercano"));
    mmc.addActionListener(this);
    menu.add(mmc);
    // Centrar aqui
    final JMenuItem cent = new JMenuItem(i18n.getString("map.menu.centerHere"), KeyEvent.VK_C);
    cent.setIcon(LogicConstants.getIcon("menucontextual_icon_centrar"));
    cent.addActionListener(this);
    menu.add(cent);
    // Nueva Incidencia
    final JMenuItem newIncidence = new JMenuItem(i18n.getString("map.menu.newIncidence"), KeyEvent.VK_I);
    newIncidence.setIcon(LogicConstants.getIcon("menucontextual_icon_newIncidence"));
    newIncidence.addActionListener(this);
    menu.add(newIncidence);
    // Calcular ruta desde aqui
    final JMenuItem from = new JMenuItem(i18n.getString("map.menu.route.from"), KeyEvent.VK_D);
    from.setIcon(LogicConstants.getIcon("menucontextual_icon_origenruta"));
    from.addActionListener(this);
    menu.add(from);
    // Calcular ruta hasta aqui
    final JMenuItem to = new JMenuItem(i18n.getString("map.menu.route.to"), KeyEvent.VK_H);
    to.setIcon(LogicConstants.getIcon("menucontextual_icon_destinoruta"));
    to.addActionListener(this);
    menu.add(to);

    menu.addSeparator();

    // Ver ficha [recurso / incidencia]
    final JMenuItem summary = new JMenuItem(i18n.getString("map.menu.summary"), KeyEvent.VK_F);
    summary.setIcon(LogicConstants.getIcon("menucontextual_icon_ficha"));
    summary.addActionListener(this);
    menu.add(summary);
    summary.setEnabled(false);

    menu.addPopupMenuListener(new PopupMenuListener() {

        @SuppressWarnings("unchecked")
        @Override
        public void popupMenuWillBecomeVisible(PopupMenuEvent e) {
            eventOriginal = FleetControlMapViewer.this.mapView.lastMEvent;
            gps.setEnabled(false);
            summary.setEnabled(false);
            titulo.setText(i18n.getString("map.menu.titulo.puntoGenerico"));
            menuObjective = null;
            Point p = new Point(mapView.lastMEvent.getX(), mapView.lastMEvent.getY());
            for (Layer l : mapView.getAllLayers()) { // por cada capa...
                if (l instanceof MarkerLayer) { // ...de marcadores
                    for (Marker marker : ((MarkerLayer) l).data) { // miramos
                        // los
                        // marcadores
                        if ((marker instanceof CustomMarker) && marker.containsPoint(p)) { // y si
                            // estamos
                            // pinchando
                            // en uno
                            CustomMarker m = (CustomMarker) marker;
                            log.trace("Hemos pinchado en " + marker);

                            switch (m.getType()) {
                            case RESOURCE:
                                Recurso r = (Recurso) m.getObject();
                                log.trace("Es un recurso: " + r);
                                if (r != null) {
                                    menuObjective = r;
                                    if (r.getPatrullas() != null) {
                                        titulo.setText(
                                                i18n.getString(Locale.ROOT, "map.menu.titulo.recursoPatrulla",
                                                        r.getIdentificador(), r.getPatrullas()));
                                    } else {
                                        titulo.setText(r.getIdentificador());
                                    }
                                    gps.setEnabled(true);
                                    summary.setEnabled(true);
                                }
                                break;
                            case INCIDENCE:
                                Incidencia i = (Incidencia) m.getObject();
                                log.trace("Es una incidencia: " + i);
                                if (i != null) {
                                    menuObjective = i;
                                    titulo.setText(i.getTitulo());
                                    gps.setEnabled(false);
                                    summary.setEnabled(true);
                                }
                                break;
                            case UNKNOWN:
                                log.trace("Hemos pinchado en un marcador desconocido");
                                break;
                            }

                        }
                    }
                }
            }
        }

        @Override
        public void popupMenuWillBecomeInvisible(PopupMenuEvent e) {
        }

        @Override
        public void popupMenuCanceled(PopupMenuEvent e) {
        }
    });

    return menu;
}

From source file:com.diversityarrays.kdxplore.KDXploreFrame.java

KDXploreFrame(ApplicationFolder appFolder, String title, int versionCode, String version,
        Closure<UpdateCheckContext> updateChecker) throws IOException {
    super(title);

    this.applicationFolder = appFolder;
    this.baseTitle = title;
    this.versionCode = versionCode;
    this.version = version;
    this.updateChecker = updateChecker;

    KdxploreConfig config = KdxploreConfig.getInstance();
    this.onlineHelpUrl = config.getOnlineHelpUrl();

    String supportEmail = config.getSupportEmail();
    if (Check.isEmpty(supportEmail)) {
        supportEmail = "someone@somewhere"; //$NON-NLS-1$
    }//from  w w  w.j  a  v  a  2 s .c o  m
    DefaultUncaughtExceptionHandler eh = new DefaultUncaughtExceptionHandler(this,
            appFolder.getApplicationName() + "_Error", //$NON-NLS-1$
            supportEmail, version + "(" + versionCode + ")"); //$NON-NLS-1$ //$NON-NLS-2$
    Thread.setDefaultUncaughtExceptionHandler(eh);
    MsgBox.DEFAULT_PROBLEM_REPORTER = eh;

    this.userDataFolder = applicationFolder.getUserDataFolder();

    this.loginUrlsProvider = new PropertiesLoginUrlsProvider(CommandArgs.getPropertiesFile(applicationFolder));

    displayVersion = RunMode.getRunMode().isDeveloper() ? version + "-dev" //$NON-NLS-1$
            : version;

    List<? extends Image> iconImages = loadIconImages();
    iconImage = iconImageBig != null ? iconImageBig : iconImageSmall;
    kdxploreIcon = new ImageIcon(iconImageSmall != null ? iconImageSmall : iconImageBig);
    setIconImages(iconImages);

    if (Util.isMacOS()) {
        try {
            System.setProperty("apple.laf.useScreenMenuBar", "true"); //$NON-NLS-1$ //$NON-NLS-2$

            macapp = new MacApplication(null);
            macapp.setAboutHandler(aboutAction);
            macapp.setQuitHandler(exitAction);
            if (iconImage != null) {
                macapp.setDockIconImage(iconImage);
            }
            macapp.setPreferencesHandler(settingsAction);
            macapp.setAboutHandler(aboutAction);
            macapp.setQuitHandler(exitAction);
        } catch (MacApplicationException e) {
            macapp = null;
            Shared.Log.w(TAG, "isMacOS", e); //$NON-NLS-1$
        }
    }

    if (iconImage != null) {
        this.setIconImage(iconImage);
    }

    clientProvider = new DefaultDALClientProvider(this, loginUrlsProvider, createBrandingImageComponent());
    clientProvider.setCanChangeUrl(false);
    clientProvider.addChangeListener(new ChangeListener() {
        @Override
        public void stateChanged(ChangeEvent e) {
            handleClientChanged();
        }
    });

    connectDisconnectActions = new ConnectDisconnectActions(clientProvider, Msg.TOOLTIP_CONNECT_TO_DATABASE(),
            Msg.TOOLTIP_DISCONNECT_FROM_DATABASE());
    connectDisconnectActions.setConnectIntercept(connectIntercept);

    desktopSupport = new DefaultDesktopSupport(KDXploreFrame.this, baseTitle);

    frameWindowOpener = new DefaultFrameWindowOpener(desktopSupport) {
        @Override
        public Image getIconImage() {
            return iconImage;
        }
    };
    frameWindowOpener.setOpenOnSameScreenAs(KDXploreFrame.this);

    setGlassPane(desktopSupport.getBlockingPane());

    setDefaultCloseOperation(DO_NOTHING_ON_CLOSE);

    addWindowListener(windowListener);

    initialiseKdxApps();

    JMenuBar mb = buildMenuBar();

    if (iconImage != null) {
        backgroundPanel.setBackgroundImage(iconImage);
    } else {
        backgroundPanel.setBackgroundImage(KDClientUtils.getImage(ImageId.DART_LOGO_128x87));
    }
    backgroundPanel.setBackground(Color.decode("0xccffff")); //$NON-NLS-1$

    splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, cardPanel, messagesPanel);
    splitPane.setResizeWeight(0.8);

    // = = = = = =

    Container cp = getContentPane();
    cp.add(splitPane, BorderLayout.CENTER);

    statusInfoLine.setHorizontalAlignment(SwingConstants.LEFT);
    logoImagesLabel = new LogoImagesLabel();
    JPanel bottom = new JPanel(new BorderLayout());
    bottom.add(statusInfoLine, BorderLayout.CENTER);
    bottom.add(logoImagesLabel, BorderLayout.EAST);
    cp.add(bottom, BorderLayout.SOUTH);

    addWindowListener(new WindowAdapter() {
        @Override
        public void windowOpened(WindowEvent e) {
            removeWindowListener(this);
            logoImagesLabel.startCycling();
        }
    });

    showCard(CARD_KDXAPPS);

    setJMenuBar(mb);

    pack();

    Dimension size = getSize();
    boolean changed = false;
    if (size.width < MINIMUM_SIZE.width) {
        size.width = MINIMUM_SIZE.width;
        changed = true;
    }
    if (size.height < MINIMUM_SIZE.height) {
        size.height = MINIMUM_SIZE.height;
        changed = true;
    }
    if (changed) {
        setSize(size);
    }

    setLocationRelativeTo(null);

    final MemoryUsageMonitor mum = new MemoryUsageMonitor();
    mum.addChangeListener(new ChangeListener() {
        @Override
        public void stateChanged(ChangeEvent e) {
            updateStatusLineWithMemoryUsage(mum.getMemoryUsage());
        }
    });
}

From source file:org.kalypsodeegree_impl.graphics.sld.Stroke_Impl.java

/**
 * The stroke CssParameter element gives the solid color that will be used for a stroke. The color value is
 * RGB-encoded using two hexadecimal digits per primary-color component, in the order Red, Green, Blue, prefixed with
 * a hash (#) sign. The hexadecimal digits between A and F may be in either uppercase or lowercase. For example, full
 * red is encoded as #ff0000 (with no quotation marks). The default color is defined to be black (#000000) in the
 * context of the LineSymbolizer, if the stroke CssParameter element is absent.
 * <p>//from w w  w  .j  a v a  2  s . c  om
 *
 * @param feature
 *          specifies the <tt>Feature</tt> to be used for evaluation of the underlying 'sld:ParameterValueType'
 * @return the (evaluated) value of the parameter
 * @throws FilterEvaluationException
 *           if the evaluation fails
 */
@Override
public Color getStroke(final Feature feature) throws FilterEvaluationException {
    Color awtColor = COLOR_DEFAULT;

    if (color == null) {
        // evaluate color depending on the passed feature's properties
        final CssParameter cssParam = getParameter(CSS_STROKE);

        if (cssParam != null) {
            final String s = cssParam.getValue(feature);

            try {
                awtColor = s == null || s.length() == 0 ? Color.BLACK : Color.decode(s);
            } catch (final NumberFormatException e) {
                throw new FilterEvaluationException("Given value ('" + s + "') for CSS-Parameter 'stroke' "
                        + "does not denote a valid color!");
            }
        }
    } else
        awtColor = color;

    return awtColor;
}

From source file:presentation.webgui.vitroappservlet.StyleCreator.java

private static JFreeChart createChart(CategoryDataset dataset, Vector<String> givCategColors,
        Model3dStylesEntry givStyleEntry) {
    String capSimpleName = givStyleEntry.getCorrCapability();
    capSimpleName = capSimpleName.replaceAll(Capability.dcaPrefix, "");
    JFreeChart chart = ChartFactory.createBarChart("Style Legend for " + capSimpleName, // chart title
            null, // domain axis label
            null, // range axis label
            dataset, // data
            PlotOrientation.HORIZONTAL, false, // include legend
            true, false);//from   w  w w. j av a 2 s .  c o m

    chart.getTitle().setFont(new Font("SansSerif", Font.BOLD, 14));
    // NOW DO SOME OPTIONAL CUSTOMISATION OF THE CHART...
    chart.setBackgroundPaint(Color.white); // seen
    CategoryPlot plot = chart.getCategoryPlot();
    chart.setPadding(new RectangleInsets(0, 0, 0, 0)); //new

    plot.setNoDataMessage("NO DATA!");

    Paint[] tmpPaintCategories = { Color.white };
    if (givCategColors.size() > 0) {
        tmpPaintCategories = new Paint[givCategColors.size()];
        for (int i = 0; i < givCategColors.size(); i++) {
            tmpPaintCategories[i] = Color.decode(givCategColors.elementAt(i));
        }
    }

    CategoryItemRenderer renderer = new CustomRenderer(tmpPaintCategories);

    renderer.setSeriesPaint(0, new Color(255, 204, 51)); //new

    plot.setRenderer(renderer);

    plot.setAxisOffset(new RectangleInsets(0, 0, 0, 0)); //new
    plot.setForegroundAlpha(1f); //new
    plot.setBackgroundAlpha(1f); //new
    plot.setInsets(new RectangleInsets(5, 0, 5, 0)); //new was 5,0,5,0
    plot.setRangeGridlinesVisible(false); //new was true
    plot.setBackgroundPaint(Color.white);//new: was (Color.lightGray);
    plot.setOutlinePaint(Color.white);

    //plot.setOrientation(PlotOrientation.HORIZONTAL);

    CategoryAxis domainAxis = plot.getDomainAxis();

    domainAxis.setLowerMargin(0.04);
    domainAxis.setUpperMargin(0.04);
    domainAxis.setVisible(true);
    domainAxis.setLabelAngle(Math.PI / 2);

    NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
    rangeAxis.setRange(0.0, 100.0); // new: was 100
    rangeAxis.setVisible(false);
    // OPTIONAL CUSTOMISATION COMPLETED.
    return chart;
}

From source file:userinterface.StateNetworkAdminRole.StateReportsJPanel.java

private JFreeChart createPatientReportsChart(CategoryDataset dataset) {
    JFreeChart barChart = ChartFactory.createBarChart("Average Waiting period of Patients", "Year",
            "Avg Waiting period(months)", dataset, PlotOrientation.VERTICAL, true, true, false);

    barChart.setBackgroundPaint(Color.white);
    // Set the background color of the chart
    barChart.getTitle().setPaint(Color.DARK_GRAY);
    barChart.setBorderVisible(true);//from   ww w . j a  v a 2  s .  c om
    // Adjust the color of the title
    CategoryPlot plot = barChart.getCategoryPlot();
    plot.getRangeAxis().setLowerBound(0.0);
    // Get the Plot object for a bar graph
    plot.setBackgroundPaint(Color.white);
    plot.setRangeGridlinePaint(Color.blue);
    CategoryItemRenderer renderer = plot.getRenderer();
    renderer.setSeriesPaint(0, Color.decode("#00008B"));
    //return chart;
    return barChart;
}

From source file:com.hp.autonomy.frontend.reports.powerpoint.PowerPointServiceImpl.java

/**
 * Internal implementation to add a topic map to a slide.
 * @param slide the slide to add to.//w  w w  .j  av  a2  s . c o m
 * @param anchor bounding rectangle to draw onto, in PowerPoint coordinates.
 * @param data the topic map data.
 */
private static void addTopicMap(final XSLFSlide slide, final Rectangle2D.Double anchor,
        final TopicMapData data) {
    for (final TopicMapData.Path reqPath : data.getPaths()) {
        final XSLFFreeformShape shape = slide.createFreeform();
        final Path2D.Double path = new Path2D.Double();

        boolean first = true;

        for (double[] point : reqPath.getPoints()) {
            final double x = point[0] * anchor.getWidth() + anchor.getMinX();
            final double y = point[1] * anchor.getHeight() + anchor.getMinY();
            if (first) {
                path.moveTo(x, y);
                first = false;
            } else {
                path.lineTo(x, y);
            }
        }
        path.closePath();

        shape.setPath(path);
        shape.setStrokeStyle(2);
        shape.setLineColor(Color.GRAY);
        shape.setHorizontalCentered(true);
        shape.setVerticalAlignment(VerticalAlignment.MIDDLE);
        shape.setTextAutofit(TextShape.TextAutofit.NORMAL);

        final XSLFTextParagraph text = shape.addNewTextParagraph();
        final XSLFTextRun textRun = text.addNewTextRun();
        textRun.setText(reqPath.name);
        textRun.setFontColor(Color.WHITE);
        textRun.setBold(true);

        final CTShape cs = (CTShape) shape.getXmlObject();

        double max = 100, min = 1, scale = 100;
        final CTTextNormalAutofit autoFit = cs.getTxBody().getBodyPr().getNormAutofit();
        final double availHeight = path.getBounds2D().getHeight();
        final int RESIZE_ATTEMPTS = 7;

        for (int attempts = 0; attempts < RESIZE_ATTEMPTS; ++attempts) {
            // PowerPoint doesn't resize the text till you edit it once, which means the text initially looks too
            //   large when you first view the slide; so we binary-chop to get a sensible initial approximation.
            // OpenOffice does the text resize on load so it doesn't have this problem.
            autoFit.setFontScale(Math.max(1, (int) (scale * 1000)));

            final double textHeight = shape.getTextHeight();
            if (textHeight < availHeight) {
                min = scale;
                scale = 0.5 * (min + max);
            } else if (textHeight > availHeight) {
                max = scale;
                scale = 0.5 * (min + max);
            } else {
                break;
            }
        }

        final int opacity = (int) (100000 * reqPath.getOpacity());
        final Color c1 = Color.decode(reqPath.getColor());
        final Color c2 = Color.decode(reqPath.getColor2());

        final CTGradientFillProperties gFill = cs.getSpPr().addNewGradFill();
        gFill.addNewLin().setAng(3300000);
        final CTGradientStopList list = gFill.addNewGsLst();

        final CTGradientStop stop1 = list.addNewGs();
        stop1.setPos(0);
        final CTSRgbColor color1 = stop1.addNewSrgbClr();
        color1.setVal(new byte[] { (byte) c1.getRed(), (byte) c1.getGreen(), (byte) c1.getBlue() });
        color1.addNewAlpha().setVal(opacity);

        final CTGradientStop stop2 = list.addNewGs();
        stop2.setPos(100000);
        final CTSRgbColor color2 = stop2.addNewSrgbClr();
        color2.setVal(new byte[] { (byte) c2.getRed(), (byte) c2.getGreen(), (byte) c2.getBlue() });
        color2.addNewAlpha().setVal(opacity);

        if (reqPath.level > 0) {
            // The nodes which aren't leaf nodes can be clicked on to hide them so you can see the nodes underneath.
            // This only works in PowerPoint; OpenOffice doesn't seem to support it. OpenOffice has its own syntax
            //   to do something similar, but we don't use it since PowerPoint treats it as corrupt.
            final String shapeId = Integer.toString(shape.getShapeId());
            final CTSlide slXML = slide.getXmlObject();

            final CTTimeNodeList childTnLst;
            final CTBuildList bldLst;
            if (!slXML.isSetTiming()) {
                final CTSlideTiming timing = slXML.addNewTiming();
                final CTTLCommonTimeNodeData ctn = timing.addNewTnLst().addNewPar().addNewCTn();
                ctn.setDur("indefinite");
                ctn.setRestart(STTLTimeNodeRestartTypeImpl.NEVER);
                ctn.setNodeType(STTLTimeNodeType.TM_ROOT);
                childTnLst = ctn.addNewChildTnLst();
                bldLst = timing.addNewBldLst();
            } else {
                final CTSlideTiming timing = slXML.getTiming();
                childTnLst = timing.getTnLst().getParArray(0).getCTn().getChildTnLst();
                bldLst = timing.getBldLst();
            }

            final CTTLTimeNodeSequence seq = childTnLst.addNewSeq();
            seq.setConcurrent(true);
            seq.setNextAc(STTLNextActionType.SEEK);
            final CTTLCommonTimeNodeData common = seq.addNewCTn();

            common.setRestart(STTLTimeNodeRestartType.WHEN_NOT_ACTIVE);
            common.setFill(STTLTimeNodeFillType.HOLD);
            common.setEvtFilter("cancelBubble");
            common.setNodeType(STTLTimeNodeType.INTERACTIVE_SEQ);

            final CTTLTimeConditionList condList = common.addNewStCondLst();
            final CTTLTimeCondition cond = condList.addNewCond();
            cond.setEvt(STTLTriggerEvent.ON_CLICK);
            cond.setDelay(0);
            cond.addNewTgtEl().addNewSpTgt().setSpid(shapeId);

            final CTTLTimeCondition endSync = common.addNewEndSync();
            endSync.setEvt(STTLTriggerEvent.END);
            endSync.setDelay(0);
            endSync.addNewRtn().setVal(STTLTriggerRuntimeNode.ALL);

            // These holdCtn* 'hold' transitions with zero delay might seem redundant; but they're exported in the
            //   PowerPoint XML, and the online PowerPoint Office365 viewer won't support the click animations
            //   unless they're present (e.g. from the 'Start Slide Show' button in the browser).
            final CTTLCommonTimeNodeData holdCtn1 = common.addNewChildTnLst().addNewPar().addNewCTn();

            holdCtn1.setFill(STTLTimeNodeFillType.HOLD);
            holdCtn1.addNewStCondLst().addNewCond().setDelay(0);

            final CTTLCommonTimeNodeData holdCtn2 = holdCtn1.addNewChildTnLst().addNewPar().addNewCTn();

            holdCtn2.setFill(STTLTimeNodeFillType.HOLD);
            holdCtn2.addNewStCondLst().addNewCond().setDelay(0);

            final CTTLCommonTimeNodeData clickCtn = holdCtn2.addNewChildTnLst().addNewPar().addNewCTn();

            clickCtn.setPresetID(10);
            clickCtn.setPresetClass(STTLTimeNodePresetClassType.EXIT);
            clickCtn.setPresetSubtype(0);
            clickCtn.setFill(STTLTimeNodeFillType.HOLD);
            clickCtn.setGrpId(0);
            clickCtn.setNodeType(STTLTimeNodeType.CLICK_EFFECT);

            clickCtn.addNewStCondLst().addNewCond().setDelay(0);

            final CTTimeNodeList clickChildTnList = clickCtn.addNewChildTnLst();

            final CTTLAnimateEffectBehavior animEffect = clickChildTnList.addNewAnimEffect();
            animEffect.setTransition(STTLAnimateEffectTransition.OUT);
            animEffect.setFilter("fade");
            final CTTLCommonBehaviorData cBhvr = animEffect.addNewCBhvr();
            final CTTLCommonTimeNodeData bhvrCtn = cBhvr.addNewCTn();

            bhvrCtn.setDur(500);
            cBhvr.addNewTgtEl().addNewSpTgt().setSpid(shapeId);

            final CTTLSetBehavior clickSet = clickChildTnList.addNewSet();
            final CTTLCommonBehaviorData clickSetBhvr = clickSet.addNewCBhvr();
            final CTTLCommonTimeNodeData hideCtn = clickSetBhvr.addNewCTn();

            hideCtn.setDur(1);
            hideCtn.setFill(STTLTimeNodeFillType.HOLD);
            hideCtn.addNewStCondLst().addNewCond().setDelay(499);

            clickSetBhvr.addNewTgtEl().addNewSpTgt().setSpid(shapeId);
            clickSetBhvr.addNewAttrNameLst().addAttrName("style.visibility");
            clickSet.addNewTo().addNewStrVal().setVal("hidden");

            final CTTLBuildParagraph bldP = bldLst.addNewBldP();
            bldP.setSpid(shapeId);
            bldP.setGrpId(0);
            bldP.setAnimBg(true);
        }
    }
}

From source file:org.pentaho.ui.xul.swing.tags.SwingDialog.java

private void createDialog() {

    if (getParent() instanceof XulDialog) {
        Object parentObj = ((SwingDialog) getParent()).getDialog();
        dialog = new JDialog((Dialog) parentObj);
        centerComp = (Component) parentObj;
    } else if (getParent() instanceof XulWindow) {

        Object parentObj = getParent().getManagedObject();
        dialog = new JDialog((Frame) parentObj);
        centerComp = (Component) parentObj;
    } else {//from  w  ww  . j a  va 2 s.  c  o m

        Document doc = getDocument();
        Element rootElement = doc.getRootElement();
        XulWindow window = null;
        if (rootElement != this) { // dialog is root, no JFrame Parent
            window = (XulWindow) rootElement;
        }

        if (window != null) {
            frame = (JFrame) window.getManagedObject();
            dialog = new JDialog(frame);
            centerComp = frame;
        } else {

            final Object context = domContainer.getOuterContext();
            if (context instanceof JFrame) {
                frame = (JFrame) context;
                centerComp = (Component) context;
                dialog = new JDialog(frame);
            } else if (context instanceof JDialog) {
                dialog = new JDialog((JDialog) context);
                centerComp = (Component) context;
            } else if (context instanceof JComponent) {
                dialog = new JDialog();
                centerComp = (Component) context;
            } else {
                dialog = new JDialog();
            }
        }
    }

    dialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
    dialog.setResizable(getResizable());
    dialog.setLayout(new BorderLayout());

    JPanel mainPanel = new JPanel(new BorderLayout());
    mainPanel.setOpaque(true);
    int pad = (this.getPadding() > -1) ? getPadding() : 3;
    mainPanel.setBorder(BorderFactory.createEmptyBorder(pad, pad, pad, pad));

    dialog.setTitle(title);
    dialog.setModal(isModal());
    dialog.add(mainPanel, BorderLayout.CENTER);
    mainPanel.add(container, BorderLayout.CENTER);
    container.setOpaque(false);

    if (this.header != null) {

        JPanel headerPanel = new JPanel(new BorderLayout());
        headerPanel.setBackground(Color.decode("#5F86C0"));
        headerPanel.setOpaque(true);
        JPanel headerPanelInner = new JPanel(new BorderLayout());
        headerPanelInner.setBorder(BorderFactory.createEmptyBorder(3, 3, 3, 3));
        headerPanelInner.setOpaque(false);

        headerPanel.setBorder(BorderFactory.createBevelBorder(BevelBorder.LOWERED, Color.decode("#8FB1E5"),
                Color.decode("#446CA9")));

        JLabel title = new JLabel(this.header.getTitle());

        title.setForeground(Color.white);
        headerPanelInner.add(title, BorderLayout.WEST);

        JLabel desc = new JLabel(this.header.getDescription());
        desc.setForeground(Color.white);
        headerPanelInner.add(desc, BorderLayout.EAST);

        headerPanel.add(headerPanelInner, BorderLayout.CENTER);

        mainPanel.add(headerPanel, BorderLayout.NORTH);
    }

    populateButtonPanel();
    mainPanel.add(buttonPanel, BorderLayout.SOUTH);
    dialog.setSize(new Dimension(getWidth(), getHeight()));
    dialog.setPreferredSize(new Dimension(getWidth(), getHeight()));
    dialog.setMinimumSize(new Dimension(getWidth(), getHeight()));

    if (this.getBgcolor() != null) {
        mainPanel.setBackground(Color.decode(this.getBgcolor()));
    }

}