List of usage examples for java.awt Color decode
public static Color decode(String nm) throws NumberFormatException
From source file:de.tsystems.mms.apm.performancesignature.PerfSigBuildActionResultsDisplay.java
private JFreeChart createTimeSeriesChart(final StaplerRequest req, final XYDataset dataset) throws UnsupportedEncodingException { String chartDashlet = req.getParameter(Messages.PerfSigBuildActionResultsDisplay_ReqParamChartDashlet()); String measure = req.getParameter(Messages.PerfSigBuildActionResultsDisplay_ReqParamMeasure()); String unit = req.getParameter(Messages.PerfSigBuildActionResultsDisplay_ReqParamUnit()); String color = req.getParameter(Messages.PerfSigBuildActionResultsDisplay_ReqParamColor()); if (StringUtils.isBlank(color)) color = Messages.PerfSigBuildActionResultsDisplay_DefaultColor(); else//w w w . j a v a2s .c om URLDecoder.decode(req.getParameter(Messages.PerfSigBuildActionResultsDisplay_ReqParamColor()), "UTF-8"); String[] timeUnits = { "ns", "ms", "s", "min", "h" }; JFreeChart chart; if (ArrayUtils.contains(timeUnits, unit)) { chart = ChartFactory.createTimeSeriesChart(PerfSigUtils.generateTitle(measure, chartDashlet), // title "time", // domain axis label unit, dataset, // data false, // include legend false, // tooltips false // urls ); } else { chart = ChartFactory.createXYBarChart(PerfSigUtils.generateTitle(measure, chartDashlet), // title "time", // domain axis label true, unit, (IntervalXYDataset) dataset, // data PlotOrientation.VERTICAL, // orientation false, // include legend false, // tooltips false // urls ); } XYPlot xyPlot = chart.getXYPlot(); xyPlot.setForegroundAlpha(0.8f); xyPlot.setRangeGridlinesVisible(true); xyPlot.setRangeGridlinePaint(Color.black); xyPlot.setOutlinePaint(null); XYItemRenderer xyitemrenderer = xyPlot.getRenderer(); if (xyitemrenderer instanceof XYLineAndShapeRenderer) { XYLineAndShapeRenderer xylineandshaperenderer = (XYLineAndShapeRenderer) xyitemrenderer; xylineandshaperenderer.setBaseShapesVisible(true); xylineandshaperenderer.setBaseShapesFilled(true); } DateAxis dateAxis = (DateAxis) xyPlot.getDomainAxis(); dateAxis.setTickMarkPosition(DateTickMarkPosition.MIDDLE); dateAxis.setDateFormatOverride(new SimpleDateFormat("HH:mm:ss")); xyitemrenderer.setSeriesPaint(0, Color.decode(color)); xyitemrenderer.setSeriesStroke(0, new BasicStroke(2)); chart.setBackgroundPaint(Color.white); return chart; }
From source file:gov.nih.nci.lmp.mimGpml.CommonHelper.java
/** * Convert hex string to color.//from w w w . j av a 2 s . co m * * @param hexStr * the hex string for a color * @return the color object */ public static Color convertHexToColor(String hexStr) { Color color = null; // Color.decode() only works if there is a '#' at the start if (hexStr.charAt(0) == '#') { Logger.log.debug("Not appending '#'"); color = Color.decode(hexStr); } else { Logger.log.debug("Appending '#'"); color = Color.decode("#" + hexStr); } return color; }
From source file:it.eng.spagobi.engines.chart.bo.ChartImpl.java
/** * configureChart reads the content of the template and sets the chart parameters. * // w ww . j a v a 2 s .c om * @param content the content */ public void configureChart(SourceBean content) { logger.debug("IN"); // common part for all charts //setting the title with parameter values if is necessary if (content.getAttribute(NAME) != null) { String titleChart = (String) content.getAttribute(NAME); String tmpTitle = titleChart; while (!tmpTitle.equals("")) { if (tmpTitle.indexOf("$P{") >= 0) { String parName = tmpTitle.substring(tmpTitle.indexOf("$P{") + 3, tmpTitle.indexOf("}")); String parValue = (parametersObject.get(parName) == null) ? "" : (String) parametersObject.get(parName); parValue = parValue.replaceAll("\'", ""); if (parValue.equals("%")) parValue = ""; int pos = tmpTitle.indexOf("$P{" + parName + "}") + (parName.length() + 4); titleChart = titleChart.replace("$P{" + parName + "}", parValue); tmpTitle = tmpTitle.substring(pos); } else tmpTitle = ""; } setName(titleChart); } else setName(""); SourceBean styleTitleSB = (SourceBean) content.getAttribute(STYLE_TITLE); if (styleTitleSB != null) { String fontS = (String) styleTitleSB.getAttribute(FONT_STYLE); String sizeS = (String) styleTitleSB.getAttribute(SIZE_STYLE); String colorS = (String) styleTitleSB.getAttribute(COLOR_STYLE); try { Color color = Color.decode(colorS); int size = Integer.valueOf(sizeS).intValue(); styleTitle = new StyleLabel(fontS, size, color); } catch (Exception e) { logger.error("Wrong style Title settings, use default"); } } SourceBean styleSubTitleSB = (SourceBean) content.getAttribute(STYLE_SUBTITLE); if (styleSubTitleSB != null) { String subTitle = (String) styleSubTitleSB.getAttribute(NAME_STYLE); if (subTitle != null) { String tmpSubTitle = subTitle; while (!tmpSubTitle.equals("")) { if (tmpSubTitle.indexOf("$P{") >= 0) { String parName = tmpSubTitle.substring(tmpSubTitle.indexOf("$P{") + 3, tmpSubTitle.indexOf("}")); String parValue = (parametersObject.get(parName) == null) ? "" : (String) parametersObject.get(parName); parValue = parValue.replaceAll("\'", ""); if (parValue.equals("%")) parValue = ""; int pos = tmpSubTitle.indexOf("$P{" + parName + "}") + (parName.length() + 4); subTitle = subTitle.replace("$P{" + parName + "}", parValue); tmpSubTitle = tmpSubTitle.substring(pos); } else tmpSubTitle = ""; } setSubName(subTitle); } else setSubName(""); String fontS = (String) styleSubTitleSB.getAttribute(FONT_STYLE); String sizeS = (String) styleSubTitleSB.getAttribute(SIZE_STYLE); String colorS = (String) styleSubTitleSB.getAttribute(COLOR_STYLE); try { Color color = Color.decode(colorS); int size = Integer.valueOf(sizeS).intValue(); styleSubTitle = new StyleLabel(fontS, size, color); } catch (Exception e) { logger.error("Wrong style SubTitle settings, use default"); } } SourceBean styleLabelsSB = (SourceBean) content.getAttribute(STYLE_LABELS_DEFAULT); if (styleLabelsSB != null) { String fontS = (String) styleLabelsSB.getAttribute(FONT_STYLE); if (fontS == null) { fontS = "Arial"; } String sizeS = (String) styleLabelsSB.getAttribute(SIZE_STYLE); if (sizeS == null) { sizeS = "12"; } String colorS = (String) styleLabelsSB.getAttribute(COLOR_STYLE); if (colorS == null) { colorS = "#000000"; } String orientationS = (String) styleLabelsSB.getAttribute(ORIENTATION_STYLE); if (orientationS == null) { orientationS = "horizontal"; } try { Color color = Color.decode(colorS); int size = Integer.valueOf(sizeS).intValue(); defaultLabelsStyle = new StyleLabel(fontS, size, color, orientationS); } catch (Exception e) { logger.error("Wrong style labels settings, use default"); } } else { defaultLabelsStyle = new StyleLabel("Arial", 12, Color.BLACK); } if (content.getAttribute("title_dimension") != null) { String titleD = ((String) content.getAttribute(TITLE_DIMENSION)); titleDimension = Integer.valueOf(titleD).intValue(); } else setTitleDimension(18); String colS = (String) content.getAttribute(COLORS_BACKGROUND); if (colS != null) { Color col = new Color(Integer.decode(colS).intValue()); if (col != null) { setColor(col); } else { setColor(Color.white); } } else { setColor(Color.white); } String widthS = (String) content.getAttribute(DIMENSION_WIDTH); String heightS = (String) content.getAttribute(DIMENSION_HEIGHT); if (widthS == null || heightS == null) { logger.warn("Width or height non defined, use default ones"); widthS = "400"; heightS = "300"; } width = Integer.valueOf(widthS).intValue(); height = Integer.valueOf(heightS).intValue(); // get all the data parameters try { Map dataParameters = new HashMap(); SourceBean dataSB = (SourceBean) content.getAttribute(CONF); List dataAttrsList = dataSB.getContainedSourceBeanAttributes(); Iterator dataAttrsIter = dataAttrsList.iterator(); while (dataAttrsIter.hasNext()) { SourceBeanAttribute paramSBA = (SourceBeanAttribute) dataAttrsIter.next(); SourceBean param = (SourceBean) paramSBA.getValue(); String nameParam = (String) param.getAttribute("name"); String valueParam = (String) param.getAttribute("value"); dataParameters.put(nameParam, valueParam); } if (dataParameters.get(CONF_DATASET) != null && !(((String) dataParameters.get(CONF_DATASET)).equalsIgnoreCase(""))) { confDataset = (String) dataParameters.get(CONF_DATASET); isLovConfDefined = true; } else { isLovConfDefined = false; } legend = true; if (dataParameters.get(LEGEND) != null && !(((String) dataParameters.get(LEGEND)).equalsIgnoreCase(""))) { String leg = (String) dataParameters.get(LEGEND); if (leg.equalsIgnoreCase("false")) legend = false; } legendPosition = "bottom"; if (dataParameters.get(LEGEND_POSITION) != null && !(((String) dataParameters.get(LEGEND_POSITION)).equalsIgnoreCase(""))) { String leg = (String) dataParameters.get(LEGEND_POSITION); if (leg.equalsIgnoreCase("bottom") || leg.equalsIgnoreCase("left") || leg.equalsIgnoreCase("right") || leg.equalsIgnoreCase("top")) legendPosition = leg; } filter = true; if (dataParameters.get(VIEW_FILTER) != null && !(((String) dataParameters.get(VIEW_FILTER)).equalsIgnoreCase(""))) { String fil = (String) dataParameters.get(VIEW_FILTER); if (fil.equalsIgnoreCase("false")) filter = false; } slider = true; if (dataParameters.get(VIEW_SLIDER) != null && !(((String) dataParameters.get(VIEW_SLIDER)).equalsIgnoreCase(""))) { String sli = (String) dataParameters.get(VIEW_SLIDER); if (sli.equalsIgnoreCase("false")) slider = false; } sliderStartFromEnd = false; if (dataParameters.get(SLIDER_START_FROM_END) != null && !(((String) dataParameters.get(SLIDER_START_FROM_END)).equalsIgnoreCase(""))) { String sli = (String) dataParameters.get(SLIDER_START_FROM_END); if (sli.equalsIgnoreCase("true")) sliderStartFromEnd = true; } positionSlider = "top"; if (dataParameters.get(POSITION_SLIDER) != null && !(((String) dataParameters.get(POSITION_SLIDER)).equalsIgnoreCase(""))) { positionSlider = (String) dataParameters.get(POSITION_SLIDER); } //reading series orders if present SourceBean sbSerieLabels = (SourceBean) content.getAttribute(SERIES_LABELS); // back compatibility if (sbSerieLabels == null) { sbSerieLabels = (SourceBean) content.getAttribute("CONF.SERIES_LABELS"); } if (sbSerieLabels != null) { seriesLabelsMap = new LinkedHashMap(); List atts = sbSerieLabels.getContainedAttributes(); String serieLabel = ""; for (Iterator iterator = atts.iterator(); iterator.hasNext();) { SourceBeanAttribute object = (SourceBeanAttribute) iterator.next(); String serieName = (String) object.getKey(); serieLabel = new String((String) object.getValue()); if (serieLabel != null) { seriesLabelsMap.put(serieName, serieLabel); } } } SourceBean styleLegendSB = (SourceBean) content.getAttribute(LEGEND_STYLE); if (styleLegendSB != null) { String fontS = (String) styleLegendSB.getAttribute(FONT_STYLE); String sizeS = (String) styleLegendSB.getAttribute(SIZE_STYLE); String colorS = (String) styleLegendSB.getAttribute(COLOR_STYLE); try { Color color = Color.decode(colorS); int size = Integer.valueOf(sizeS).intValue(); styleLegend = new StyleLabel(fontS, size, color); } catch (Exception e) { logger.error("Wrong style Legend settings, use default"); } } } catch (Exception e) { logger.error(e.getCause() + " " + e.getStackTrace()); logger.error("many error in reading data source parameters", e); } }
From source file:org.n52.server.io.render.DiagramRenderer.java
/** * <pre>/*from w w w . j a v a2 s .com*/ * dataset := associated to one range-axis; * corresponds to one observedProperty; * may contain multiple series; * series := corresponds to a time series for one foi * </pre> * * . * * @param entireCollMap * the entire coll map * @param options * the options * @param begin * the begin * @param end * the end * @param compress * @return the j free chart */ public JFreeChart renderChart(Map<String, OXFFeatureCollection> entireCollMap, DesignOptions options, Calendar begin, Calendar end, boolean compress) { DesignDescriptionList designDescriptions = buildUpDesignDescriptionList(options); /*** FIRST RUN ***/ JFreeChart chart = initializeTimeSeriesChart(); chart.setBackgroundPaint(Color.white); if (!this.isOverview) { chart.addSubtitle(new TextTitle(ConfigurationContext.COPYRIGHT, new Font(LABEL_FONT, Font.PLAIN, 9), Color.black, RectangleEdge.BOTTOM, HorizontalAlignment.RIGHT, VerticalAlignment.BOTTOM, new RectangleInsets(0, 0, 20, 20))); } XYPlot plot = (XYPlot) chart.getPlot(); plot.setBackgroundPaint(Color.white); plot.setDomainGridlinePaint(Color.lightGray); plot.setRangeGridlinePaint(Color.lightGray); plot.setAxisOffset(new RectangleInsets(2.0, 2.0, 2.0, 2.0)); plot.setDomainCrosshairVisible(true); plot.setRangeCrosshairVisible(true); plot.setDomainGridlinesVisible(options.getGrid()); plot.setRangeGridlinesVisible(options.getGrid()); // add additional datasets: DateAxis dateAxis = (DateAxis) plot.getDomainAxis(); dateAxis.setRange(begin.getTime(), end.getTime()); dateAxis.setDateFormatOverride(new SimpleDateFormat()); dateAxis.setTimeZone(end.getTimeZone()); // add all axes String[] phenomenaIds = options.getAllPhenomenIds(); // all the axis indices to map them later HashMap<String, Integer> axes = new HashMap<String, Integer>(); for (int i = 0; i < phenomenaIds.length; i++) { axes.put(phenomenaIds[i], i); plot.setRangeAxis(i, new NumberAxis(phenomenaIds[i])); } // list range markers ArrayList<ValueMarker> referenceMarkers = new ArrayList<ValueMarker>(); HashMap<String, double[]> referenceBounds = new HashMap<String, double[]>(); // create all TS collections for (int i = 0; i < options.getProperties().size(); i++) { TimeseriesProperties prop = options.getProperties().get(i); String phenomenonId = prop.getPhenomenon(); TimeSeriesCollection dataset = createDataset(entireCollMap, prop, phenomenonId, compress); dataset.setGroup(new DatasetGroup(prop.getTimeseriesId())); XYDataset additionalDataset = dataset; NumberAxis axe = (NumberAxis) plot.getRangeAxis(axes.get(phenomenonId)); if (this.isOverview) { axe.setAutoRange(true); axe.setAutoRangeIncludesZero(false); } else if (prop.getAxisUpperBound() == prop.getAxisLowerBound() || prop.isAutoScale()) { if (prop.isZeroScaled()) { axe.setAutoRangeIncludesZero(true); } else { axe.setAutoRangeIncludesZero(false); } } else { if (prop.isZeroScaled()) { if (axe.getUpperBound() < prop.getAxisUpperBound()) { axe.setUpperBound(prop.getAxisUpperBound()); } if (axe.getLowerBound() > prop.getAxisLowerBound()) { axe.setLowerBound(prop.getAxisLowerBound()); } } else { axe.setRange(prop.getAxisLowerBound(), prop.getAxisUpperBound()); axe.setAutoRangeIncludesZero(false); } } plot.setDataset(i, additionalDataset); plot.mapDatasetToRangeAxis(i, axes.get(phenomenonId)); // set bounds new for reference values if (!referenceBounds.containsKey(phenomenonId)) { double[] bounds = new double[] { axe.getLowerBound(), axe.getUpperBound() }; referenceBounds.put(phenomenonId, bounds); } else { double[] bounds = referenceBounds.get(phenomenonId); if (bounds[0] >= axe.getLowerBound()) { bounds[0] = axe.getLowerBound(); } if (bounds[1] <= axe.getUpperBound()) { bounds[1] = axe.getUpperBound(); } } double[] bounds = referenceBounds.get(phenomenonId); for (String string : prop.getReferenceValues()) { if (prop.getRefValue(string).show()) { Double value = prop.getRefValue(string).getValue(); if (value <= bounds[0]) { bounds[0] = value; } else if (value >= bounds[1]) { bounds[1] = value; } } } Axis axis = prop.getAxis(); if (axis == null) { axis = new Axis(axe.getUpperBound(), axe.getLowerBound()); } else if (prop.isAutoScale()) { axis.setLowerBound(axe.getLowerBound()); axis.setUpperBound(axe.getUpperBound()); axis.setMaxY(axis.getMaxY()); axis.setMinY(axis.getMinY()); } prop.setAxisData(axis); this.axisMapping.put(prop.getTimeseriesId(), axis); for (String string : prop.getReferenceValues()) { if (prop.getRefValue(string).show()) { referenceMarkers.add(new ValueMarker(prop.getRefValue(string).getValue(), Color.decode(prop.getRefValue(string).getColor()), new BasicStroke(1.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND, 1.0f))); } } plot.mapDatasetToRangeAxis(i, axes.get(phenomenonId)); } for (ValueMarker valueMarker : referenceMarkers) { plot.addRangeMarker(valueMarker); } // show actual time ValueMarker nowMarker = new ValueMarker(System.currentTimeMillis(), Color.orange, new BasicStroke(1.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND, 1.0f)); plot.addDomainMarker(nowMarker); if (!this.isOverview) { Iterator<Entry<String, double[]>> iterator = referenceBounds.entrySet().iterator(); while (iterator.hasNext()) { Entry<String, double[]> boundsEntry = iterator.next(); String phenId = boundsEntry.getKey(); NumberAxis axe = (NumberAxis) plot.getRangeAxis(axes.get(phenId)); axe.setAutoRange(true); // add a margin double marginOffset = (boundsEntry.getValue()[1] - boundsEntry.getValue()[0]) / 25; boundsEntry.getValue()[0] -= marginOffset; boundsEntry.getValue()[1] += marginOffset; axe.setRange(boundsEntry.getValue()[0], boundsEntry.getValue()[1]); } } /**** SECOND RUN ***/ // set domain axis labels: plot.getDomainAxis().setLabelFont(label); plot.getDomainAxis().setLabelPaint(LABEL_COLOR); plot.getDomainAxis().setTickLabelFont(tickLabelDomain); plot.getDomainAxis().setTickLabelPaint(LABEL_COLOR); plot.getDomainAxis().setLabel(designDescriptions.getDomainAxisLabel()); // define the design for each series: for (int datasetIndex = 0; datasetIndex < plot.getDatasetCount(); datasetIndex++) { TimeSeriesCollection dataset = (TimeSeriesCollection) plot.getDataset(datasetIndex); for (int seriesIndex = 0; seriesIndex < dataset.getSeriesCount(); seriesIndex++) { String timeseriesId = (String) dataset.getSeries(seriesIndex).getKey(); RenderingDesign dd = designDescriptions.get(timeseriesId); if (dd != null) { // LINESTYLE: String lineStyle = dd.getLineStyle(); int width = dd.getLineWidth(); if (this.isOverview) { width = width / 2; width = (width == 0) ? 1 : width; } // "1" is lineStyle "line" if (lineStyle.equalsIgnoreCase(LINE)) { XYLineAndShapeRenderer ren = new XYLineAndShapeRenderer(true, false); ren.setStroke(new BasicStroke(width)); plot.setRenderer(datasetIndex, ren); } // "2" is lineStyle "area" else if (lineStyle.equalsIgnoreCase(AREA)) { plot.setRenderer(datasetIndex, new XYAreaRenderer()); } // "3" is lineStyle "dotted" else if (lineStyle.equalsIgnoreCase(DOTTED)) { XYLineAndShapeRenderer ren = new XYLineAndShapeRenderer(false, true); ren.setShape(new Ellipse2D.Double(-width, -width, 2 * width, 2 * width)); plot.setRenderer(datasetIndex, ren); } // "4" is dashed else if (lineStyle.equalsIgnoreCase("4")) { // dashed XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(true, false); renderer.setSeriesStroke(0, new BasicStroke(width, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND, 1.0f, new float[] { 4.0f * width, 4.0f * width }, 0.0f)); plot.setRenderer(datasetIndex, renderer); } else if (lineStyle.equalsIgnoreCase("5")) { // lines and dots XYLineAndShapeRenderer ren = new XYLineAndShapeRenderer(true, true); int thickness = 2 * width; ren.setShape(new Ellipse2D.Double(-width, -width, thickness, thickness)); ren.setStroke(new BasicStroke(width)); plot.setRenderer(datasetIndex, ren); } else { // default is lineStyle "line" plot.setRenderer(datasetIndex, new XYLineAndShapeRenderer(true, false)); } plot.getRenderer(datasetIndex).setSeriesPaint(seriesIndex, dd.getColor()); // plot.getRenderer(datasetIndex).setShapesVisible(true); XYToolTipGenerator toolTipGenerator = StandardXYToolTipGenerator.getTimeSeriesInstance(); XYURLGenerator urlGenerator = new MetadataInURLGenerator(designDescriptions); plot.getRenderer(datasetIndex).setBaseToolTipGenerator(toolTipGenerator); plot.getRenderer(datasetIndex).setURLGenerator(urlGenerator); // GRID: // PROBLEM: JFreeChart only allows to switch the grid on/off // for the whole XYPlot. And the // grid will always be displayed for the first series in the // plot. I'll always show the // grid. // --> plot.setDomainGridlinesVisible(visible) // RANGE AXIS LABELS: if (isOverview) { plot.getRangeAxisForDataset(datasetIndex).setTickLabelsVisible(false); plot.getRangeAxisForDataset(datasetIndex).setTickMarksVisible(false); plot.getRangeAxisForDataset(datasetIndex).setVisible(false); } else { plot.getRangeAxisForDataset(datasetIndex).setLabelFont(label); plot.getRangeAxisForDataset(datasetIndex).setLabelPaint(LABEL_COLOR); plot.getRangeAxisForDataset(datasetIndex).setTickLabelFont(tickLabelDomain); plot.getRangeAxisForDataset(datasetIndex).setTickLabelPaint(LABEL_COLOR); StringBuilder unitOfMeasure = new StringBuilder(); unitOfMeasure.append(dd.getPhenomenon().getLabel()); String uomLabel = dd.getUomLabel(); if (uomLabel != null && !uomLabel.isEmpty()) { unitOfMeasure.append(" (").append(uomLabel).append(")"); } plot.getRangeAxisForDataset(datasetIndex).setLabel(unitOfMeasure.toString()); } } } } return chart; }
From source file:net.java.sip.communicator.impl.gui.main.chat.ChatPanel.java
/** * Sets the chat session to associate to this chat panel. * @param chatSession the chat session to associate to this chat panel *///from w w w . j av a2 s.c om public void setChatSession(ChatSession chatSession) { if (this.chatSession != null) { // remove old listener this.chatSession.removeChatTransportChangeListener(this); } this.chatSession = chatSession; this.chatSession.addChatTransportChangeListener(this); if ((this.chatSession != null) && this.chatSession.isContactListSupported()) { topPanel.remove(conversationPanelContainer); TransparentPanel rightPanel = new TransparentPanel(new BorderLayout()); Dimension chatConferencesListsPanelSize = new Dimension(150, 25); Dimension chatContactsListsPanelSize = new Dimension(150, 175); Dimension rightPanelSize = new Dimension(150, 200); rightPanel.setMinimumSize(rightPanelSize); rightPanel.setPreferredSize(rightPanelSize); TransparentPanel contactsPanel = new TransparentPanel(new BorderLayout()); contactsPanel.setMinimumSize(chatContactsListsPanelSize); contactsPanel.setPreferredSize(chatContactsListsPanelSize); conferencePanel.setMinimumSize(chatConferencesListsPanelSize); conferencePanel.setPreferredSize(chatConferencesListsPanelSize); this.chatContactListPanel = new ChatRoomMemberListPanel(this); this.chatContactListPanel.setOpaque(false); topSplitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT); topSplitPane.setBorder(null); // remove default borders topSplitPane.setOneTouchExpandable(true); topSplitPane.setOpaque(false); topSplitPane.setResizeWeight(1.0D); Color msgNameBackground = Color.decode(ChatHtmlUtils.MSG_NAME_BACKGROUND); // add border to the divider if (topSplitPane.getUI() instanceof BasicSplitPaneUI) { ((BasicSplitPaneUI) topSplitPane.getUI()).getDivider() .setBorder(BorderFactory.createLineBorder(msgNameBackground)); } ChatTransport chatTransport = chatSession.getCurrentChatTransport(); JPanel localUserLabelPanel = new JPanel(new BorderLayout()); JLabel localUserLabel = new JLabel(chatTransport.getProtocolProvider().getAccountID().getDisplayName()); localUserLabel.setFont(localUserLabel.getFont().deriveFont(Font.BOLD)); localUserLabel.setHorizontalAlignment(SwingConstants.CENTER); localUserLabel.setBorder(BorderFactory.createEmptyBorder(2, 0, 3, 0)); localUserLabel.setForeground(Color.decode(ChatHtmlUtils.MSG_IN_NAME_FOREGROUND)); localUserLabelPanel.add(localUserLabel, BorderLayout.CENTER); localUserLabelPanel.setBackground(msgNameBackground); JButton joinConference = new JButton( GuiActivator.getResources().getI18NString("service.gui.JOIN_VIDEO")); joinConference.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { showChatConferenceDialog(); } }); contactsPanel.add(localUserLabelPanel, BorderLayout.NORTH); contactsPanel.add(chatContactListPanel, BorderLayout.CENTER); conferencePanel.add(joinConference, BorderLayout.CENTER); rightPanel.add(conferencePanel, BorderLayout.NORTH); rightPanel.add(contactsPanel, BorderLayout.CENTER); topSplitPane.setLeftComponent(conversationPanelContainer); topSplitPane.setRightComponent(rightPanel); topPanel.add(topSplitPane); } else { if (topSplitPane != null) { if (chatContactListPanel != null) { topSplitPane.remove(chatContactListPanel); chatContactListPanel = null; } this.messagePane.remove(topSplitPane); topSplitPane = null; } topPanel.add(conversationPanelContainer); } if (chatSession instanceof MetaContactChatSession) { // The subject panel is added here, because it's specific for the // multi user chat and is not contained in the single chat chat panel. if (subjectPanel != null) { this.remove(subjectPanel); subjectPanel = null; this.revalidate(); this.repaint(); } writeMessagePanel.initPluginComponents(); writeMessagePanel.setTransportSelectorBoxVisible(true); //Enables to change the protocol provider by simply pressing the // CTRL-P key combination ActionMap amap = this.getActionMap(); amap.put("ChangeProtocol", new ChangeTransportAction()); InputMap imap = this.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW); imap.put(KeyStroke.getKeyStroke(KeyEvent.VK_P, KeyEvent.CTRL_DOWN_MASK), "ChangeProtocol"); } else if (chatSession instanceof ConferenceChatSession) { ConferenceChatSession confSession = (ConferenceChatSession) chatSession; writeMessagePanel.setTransportSelectorBoxVisible(false); confSession.addLocalUserRoleListener(this); confSession.addMemberRoleListener(this); ChatRoom room = ((ChatRoomWrapper) chatSession.getDescriptor()).getChatRoom(); room.addMemberPropertyChangeListener(this); setConferencesPanelVisible(room.getCachedConferenceDescriptionSize() > 0); subjectPanel = new ChatRoomSubjectPanel((ConferenceChatSession) chatSession); // The subject panel is added here, because it's specific for the // multi user chat and is not contained in the single chat chat panel. this.add(subjectPanel, BorderLayout.NORTH); this.revalidate(); this.repaint(); } if (chatContactListPanel != null) { // Initialize chat participants' panel. Iterator<ChatContact<?>> chatParticipants = chatSession.getParticipants(); while (chatParticipants.hasNext()) chatContactListPanel.addContact(chatParticipants.next()); } }
From source file:com.github.fcannizzaro.resourcer.Resourcer.java
/** * Parse values xml files//from w w w .j a v a2 s . com */ private static void findValues() { values = new HashMap<>(); File dir = new File(PATH_BASE + VALUES_DIR); if (!dir.isDirectory()) return; File[] files = dir.listFiles(); if (files == null) return; for (File file : files) // only *.xml files if (file.getName().matches(".*\\.xml$")) { Document doc = FileUtils.readXML(file.getAbsolutePath()); if (doc == null) return; Element ele = doc.getDocumentElement(); for (String element : elements) { NodeList list = ele.getElementsByTagName(element); if (values.get(element) == null) values.put(element, new HashMap<>()); for (int j = 0; j < list.getLength(); j++) { Element node = (Element) list.item(j); String value = node.getFirstChild().getNodeValue(); Object valueDefined = value; switch (element) { case INTEGER: valueDefined = Integer.valueOf(value); break; case DOUBLE: valueDefined = Double.valueOf(value); break; case FLOAT: valueDefined = Float.valueOf(value); break; case BOOLEAN: valueDefined = Boolean.valueOf(value); break; case LONG: valueDefined = Long.valueOf(value); break; case COLOR: if (value.matches("@color/.*")) { try { Class<?> c = Class.forName("com.github.fcannizzaro.material.Colors"); Object colors = c.getDeclaredField(value.replace("@color/", "")).get(c); Method asColor = c.getMethod("asColor"); valueDefined = asColor.invoke(colors); } catch (Exception e) { System.out.println("ERROR Resourcer - Cannot bind " + value); } } else valueDefined = Color.decode(value); break; } values.get(node.getNodeName()).put(node.getAttribute("name"), valueDefined); } } } }
From source file:org.openestate.is24.restapi.utils.XmlUtils.java
/** * Read a {@link Color} value from XML.//from w ww .ja va 2s . c o m * * @param value * XML string * * @return * parsed value */ public static Color parseColor(String value) { String val = StringUtils.trimToNull(value); if (val == null) return null; if (val.startsWith("#")) val = val.substring(1); if (!val.startsWith("0x")) val = "0x" + val; return Color.decode(val); }
From source file:it.eng.spagobi.engines.chart.bo.charttypes.targetcharts.TargetCharts.java
public void configureChart(SourceBean content) { logger.debug("IN"); super.configureChart(content); confParameters = new HashMap<String, String>(); SourceBean confSB = (SourceBean) content.getAttribute("CONF"); if (confSB == null) return;//from w w w. java 2 s . c o m List confAttrsList = confSB.getAttributeAsList("PARAMETER"); Iterator confAttrsIter = confAttrsList.iterator(); while (confAttrsIter.hasNext()) { SourceBean param = (SourceBean) confAttrsIter.next(); String nameParam = (String) param.getAttribute("name"); String valueParam = (String) param.getAttribute("value"); confParameters.put(nameParam, valueParam); } //check if targets or baselines are defined as parameters, if not then search for them in template //**************************** PARAMETERES TARGET OR BASELINES DEFINITION ********************** boolean targets = false; boolean baselines = false; boolean parameterThresholdDefined = false; Vector<String> targetNames = new Vector<String>(); Vector<String> baselinesNames = new Vector<String>(); for (Iterator iterator = parametersObject.keySet().iterator(); iterator.hasNext();) { String name = (String) iterator.next(); Object value = parametersObject.get(name); if (name.startsWith("target") && !value.toString().equalsIgnoreCase("[]")) { targets = true; targetNames.add(name); } if (name.startsWith("baseline") && !value.toString().equalsIgnoreCase("[]")) { // if targets are used baseline will be ignored baselines = true; baselinesNames.add(name); } } if (targets == true) { // Case Target Found on parameters useTargets = true; for (Iterator iterator = targetNames.iterator(); iterator.hasNext();) { String targetName = (String) iterator.next(); String valueToParse = (String) parametersObject.get(targetName); TargetThreshold targThres = new TargetThreshold(valueToParse); if (targThres.getName().equalsIgnoreCase("bottom")) bottomThreshold = targThres; else { if (targThres.isVisible()) { thresholds.put(targThres.getValue(), targThres); if (targThres.isMain() == true) mainThreshold = targThres.getValue(); } } } if (bottomThreshold == null) bottomThreshold = new TargetThreshold("bottom", null, Color.BLACK, false, true); } else if (baselines == true) { // Case Baselines found on parameters useTargets = false; for (Iterator iterator = baselinesNames.iterator(); iterator.hasNext();) { String targetName = (String) iterator.next(); String valueToParse = (String) parametersObject.get(targetName); TargetThreshold targThres = new TargetThreshold(valueToParse); if (targThres.getName().equalsIgnoreCase("bottom")) bottomThreshold = targThres; else { if (targThres.isVisible()) { thresholds.put(targThres.getValue(), targThres); if (targThres.isMain() == true) mainThreshold = targThres.getValue(); } } } if (bottomThreshold == null) bottomThreshold = new TargetThreshold("bottom", null, Color.BLACK, false, true); } //**************************** TEMPLATE TARGET OR BASELINES DEFINITION ********************** else { // Case targets or baselines defined in template /* <TARGETS> * <TARGET name='first' value='5' main='true'> * </TARGETS> */ List thresAttrsList = null; SourceBean thresholdsSB = (SourceBean) content.getAttribute(TARGETS); if (thresholdsSB == null) { thresholdsSB = (SourceBean) content.getAttribute(BASELINES); if (thresholdsSB == null) return; useTargets = false; } if (thresholdsSB != null) { thresAttrsList = thresholdsSB.getContainedSourceBeanAttributes(); } if (thresAttrsList == null || thresAttrsList.isEmpty()) { logger.error("targets or baselines not defined; error "); return; } else { thresholds = new HashMap<Double, TargetThreshold>(); //thresholdColors=new HashMap<String, Color>(); Iterator targetsAttrsIter = thresAttrsList.iterator(); while (targetsAttrsIter.hasNext()) { SourceBeanAttribute paramSBA = (SourceBeanAttribute) targetsAttrsIter.next(); SourceBean param = (SourceBean) paramSBA.getValue(); String name = (String) param.getAttribute("name"); String value = (String) param.getAttribute("value"); String main = (String) param.getAttribute("main"); String colorS = (String) param.getAttribute("color"); String visibleS = (String) param.getAttribute("visible"); Color colorC = Color.BLACK; boolean isMain = (main != null && main.equalsIgnoreCase("true")) ? true : false; if (colorS != null) { try { colorC = Color.decode(colorS); } catch (Exception e) { logger.error("error in color defined, put BLACK as default"); } } boolean isVisible = (visibleS != null && (visibleS.equalsIgnoreCase("false") || visibleS.equalsIgnoreCase("0") || visibleS.equalsIgnoreCase("0.0"))) ? false : true; // The value of the threshold is bottom or a double value if (value != null) { if (value.equalsIgnoreCase("bottom")) { //if definin bottom case bottomThreshold = new TargetThreshold("bottom", null, colorC, false, true); } else if (!value.equalsIgnoreCase("bottom")) { Double valueD = null; try { valueD = Double.valueOf(value); } catch (NumberFormatException e) { logger.error("Error in converting threshold double", e); return; } if (isVisible == true) { thresholds.put(valueD, new TargetThreshold(name, valueD, colorC, isMain, isVisible)); if (isMain == true) { mainThreshold = valueD; } } } } } } // Template definition } if (confParameters.get(WLT_MODE) != null) { String wltModeS = (String) confParameters.get(WLT_MODE); wlt_mode = Double.valueOf(wltModeS); } if (confParameters.get(MAXIMUM_BAR_WIDTH) != null) { String maxBarWidthS = (String) confParameters.get(MAXIMUM_BAR_WIDTH); try { maxBarWidth = Double.valueOf(maxBarWidthS); } catch (NumberFormatException e) { logger.error("error in defining parameter " + MAXIMUM_BAR_WIDTH + ": should be a double, it will be ignored", e); } } SourceBean styleValueLabelsSB = (SourceBean) content.getAttribute(STYLE_VALUE_LABELS); if (styleValueLabelsSB != null) { String fontS = (String) styleValueLabelsSB.getAttribute(FONT_STYLE); if (fontS == null) { fontS = defaultLabelsStyle.getFontName(); } String sizeS = (String) styleValueLabelsSB.getAttribute(SIZE_STYLE); String colorS = (String) styleValueLabelsSB.getAttribute(COLOR_STYLE); String orientationS = (String) styleValueLabelsSB.getAttribute(ORIENTATION_STYLE); if (orientationS == null) { orientationS = "horizontal"; } try { Color color = Color.BLACK; if (colorS != null) { color = Color.decode(colorS); } else { defaultLabelsStyle.getColor(); } int size = 12; if (sizeS != null) { size = Integer.valueOf(sizeS).intValue(); } else { size = defaultLabelsStyle.getSize(); } styleValueLabels = new StyleLabel(fontS, size, color, orientationS); } catch (Exception e) { logger.error("Wrong style labels settings, use default"); } } else { styleValueLabels = defaultLabelsStyle; } logger.debug("OUT"); }
From source file:org.n52.server.sos.render.DiagramRenderer.java
/** * <pre>//from w w w .java 2s . co m * dataset := associated to one range-axis; * corresponds to one observedProperty; * may contain multiple series; * series := corresponds to a time series for one foi * </pre> * * . * * @param entireCollMap * the entire coll map * @param options * the options * @param begin * the begin * @param end * the end * @param compress * @return the j free chart */ public JFreeChart renderChart(Map<String, OXFFeatureCollection> entireCollMap, DesignOptions options, Calendar begin, Calendar end, boolean compress) { DesignDescriptionList designDescriptions = buildUpDesignDescriptionList(options); /*** FIRST RUN ***/ JFreeChart chart = initializeTimeSeriesChart(); chart.setBackgroundPaint(Color.white); if (!this.isOverview) { chart.addSubtitle(new TextTitle(ConfigurationContext.COPYRIGHT, new Font(LABEL_FONT, Font.PLAIN, 9), Color.black, RectangleEdge.BOTTOM, HorizontalAlignment.RIGHT, VerticalAlignment.BOTTOM, new RectangleInsets(0, 0, 20, 20))); } XYPlot plot = (XYPlot) chart.getPlot(); plot.setBackgroundPaint(Color.white); plot.setDomainGridlinePaint(Color.lightGray); plot.setRangeGridlinePaint(Color.lightGray); plot.setAxisOffset(new RectangleInsets(2.0, 2.0, 2.0, 2.0)); plot.setDomainCrosshairVisible(true); plot.setRangeCrosshairVisible(true); plot.setDomainGridlinesVisible(options.getGrid()); plot.setRangeGridlinesVisible(options.getGrid()); // add additional datasets: DateAxis dateAxis = (DateAxis) plot.getDomainAxis(); dateAxis.setRange(begin.getTime(), end.getTime()); dateAxis.setDateFormatOverride(new SimpleDateFormat()); // add all axes String[] phenomenaIds = options.getAllPhenomenIds(); // all the axis indices to map them later HashMap<String, Integer> axes = new HashMap<String, Integer>(); for (int i = 0; i < phenomenaIds.length; i++) { axes.put(phenomenaIds[i], i); plot.setRangeAxis(i, new NumberAxis(phenomenaIds[i])); } // list range markers ArrayList<ValueMarker> referenceMarkers = new ArrayList<ValueMarker>(); HashMap<String, double[]> referenceBounds = new HashMap<String, double[]>(); // create all TS collections for (int i = 0; i < options.getProperties().size(); i++) { TimeseriesProperties prop = options.getProperties().get(i); String phenomenonId = prop.getPhenomenon(); TimeSeriesCollection dataset = createDataset(entireCollMap, prop, phenomenonId, compress); dataset.setGroup(new DatasetGroup(prop.getTimeseriesId())); XYDataset additionalDataset = dataset; NumberAxis axe = (NumberAxis) plot.getRangeAxis(axes.get(phenomenonId)); if (this.isOverview) { axe.setAutoRange(true); axe.setAutoRangeIncludesZero(false); } else if (prop.getAxisUpperBound() == prop.getAxisLowerBound() || prop.isAutoScale()) { if (prop.isZeroScaled()) { axe.setAutoRangeIncludesZero(true); } else { axe.setAutoRangeIncludesZero(false); } } else { if (prop.isZeroScaled()) { if (axe.getUpperBound() < prop.getAxisUpperBound()) { axe.setUpperBound(prop.getAxisUpperBound()); } if (axe.getLowerBound() > prop.getAxisLowerBound()) { axe.setLowerBound(prop.getAxisLowerBound()); } } else { axe.setRange(prop.getAxisLowerBound(), prop.getAxisUpperBound()); axe.setAutoRangeIncludesZero(false); } } plot.setDataset(i, additionalDataset); plot.mapDatasetToRangeAxis(i, axes.get(phenomenonId)); // set bounds new for reference values if (!referenceBounds.containsKey(phenomenonId)) { double[] bounds = new double[] { axe.getLowerBound(), axe.getUpperBound() }; referenceBounds.put(phenomenonId, bounds); } else { double[] bounds = referenceBounds.get(phenomenonId); if (bounds[0] >= axe.getLowerBound()) { bounds[0] = axe.getLowerBound(); } if (bounds[1] <= axe.getUpperBound()) { bounds[1] = axe.getUpperBound(); } } double[] bounds = referenceBounds.get(phenomenonId); for (String string : prop.getReferenceValues()) { if (prop.getRefValue(string).show()) { Double value = prop.getRefValue(string).getValue(); if (value <= bounds[0]) { bounds[0] = value; } else if (value >= bounds[1]) { bounds[1] = value; } } } Axis axis = prop.getAxis(); if (axis == null) { axis = new Axis(axe.getUpperBound(), axe.getLowerBound()); } else if (prop.isAutoScale()) { axis.setLowerBound(axe.getLowerBound()); axis.setUpperBound(axe.getUpperBound()); axis.setMaxY(axis.getMaxY()); axis.setMinY(axis.getMinY()); } prop.setAxisData(axis); this.axisMapping.put(prop.getTimeseriesId(), axis); for (String string : prop.getReferenceValues()) { if (prop.getRefValue(string).show()) { referenceMarkers.add(new ValueMarker(prop.getRefValue(string).getValue(), Color.decode(prop.getRefValue(string).getColor()), new BasicStroke(1.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND, 1.0f))); } } plot.mapDatasetToRangeAxis(i, axes.get(phenomenonId)); } for (ValueMarker valueMarker : referenceMarkers) { plot.addRangeMarker(valueMarker); } // show actual time ValueMarker nowMarker = new ValueMarker(System.currentTimeMillis(), Color.orange, new BasicStroke(1.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND, 1.0f)); plot.addDomainMarker(nowMarker); if (!this.isOverview) { Iterator<Entry<String, double[]>> iterator = referenceBounds.entrySet().iterator(); while (iterator.hasNext()) { Entry<String, double[]> boundsEntry = iterator.next(); String phenId = boundsEntry.getKey(); NumberAxis axe = (NumberAxis) plot.getRangeAxis(axes.get(phenId)); axe.setAutoRange(true); // add a margin double marginOffset = (boundsEntry.getValue()[1] - boundsEntry.getValue()[0]) / 25; boundsEntry.getValue()[0] -= marginOffset; boundsEntry.getValue()[1] += marginOffset; axe.setRange(boundsEntry.getValue()[0], boundsEntry.getValue()[1]); } } /**** SECOND RUN ***/ // set domain axis labels: plot.getDomainAxis().setLabelFont(label); plot.getDomainAxis().setLabelPaint(LABEL_COLOR); plot.getDomainAxis().setTickLabelFont(tickLabelDomain); plot.getDomainAxis().setTickLabelPaint(LABEL_COLOR); plot.getDomainAxis().setLabel(designDescriptions.getDomainAxisLabel()); // define the design for each series: for (int datasetIndex = 0; datasetIndex < plot.getDatasetCount(); datasetIndex++) { TimeSeriesCollection dataset = (TimeSeriesCollection) plot.getDataset(datasetIndex); for (int seriesIndex = 0; seriesIndex < dataset.getSeriesCount(); seriesIndex++) { String timeseriesId = (String) dataset.getSeries(seriesIndex).getKey(); RenderingDesign dd = designDescriptions.get(timeseriesId); if (dd != null) { // LINESTYLE: String lineStyle = dd.getLineStyle(); int width = dd.getLineWidth(); if (this.isOverview) { width = width / 2; width = (width == 0) ? 1 : width; } // "1" is lineStyle "line" if (lineStyle.equalsIgnoreCase(LINE)) { XYLineAndShapeRenderer ren = new XYLineAndShapeRenderer(true, false); ren.setStroke(new BasicStroke(width)); plot.setRenderer(datasetIndex, ren); } // "2" is lineStyle "area" else if (lineStyle.equalsIgnoreCase(AREA)) { plot.setRenderer(datasetIndex, new XYAreaRenderer()); } // "3" is lineStyle "dotted" else if (lineStyle.equalsIgnoreCase(DOTTED)) { XYLineAndShapeRenderer ren = new XYLineAndShapeRenderer(false, true); ren.setShape(new Ellipse2D.Double(-width, -width, 2 * width, 2 * width)); plot.setRenderer(datasetIndex, ren); } // "4" is dashed else if (lineStyle.equalsIgnoreCase("4")) { XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(true, false); renderer.setSeriesStroke(0, new BasicStroke(width, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND, 1.0f, new float[] { 4.0f * width, 4.0f * width }, 0.0f)); plot.setRenderer(datasetIndex, renderer); } else if (lineStyle.equalsIgnoreCase("5")) { // lines and dots XYLineAndShapeRenderer ren = new XYLineAndShapeRenderer(true, true); int thickness = 2 * width; ren.setShape(new Ellipse2D.Double(-width, -width, thickness, thickness)); ren.setStroke(new BasicStroke(width)); plot.setRenderer(datasetIndex, ren); } else { // default is lineStyle "line" plot.setRenderer(datasetIndex, new XYLineAndShapeRenderer(true, false)); } plot.getRenderer(datasetIndex).setSeriesPaint(seriesIndex, dd.getColor()); // plot.getRenderer(datasetIndex).setShapesVisible(true); XYToolTipGenerator toolTipGenerator = StandardXYToolTipGenerator.getTimeSeriesInstance(); XYURLGenerator urlGenerator = new MetadataInURLGenerator(designDescriptions); plot.getRenderer(datasetIndex).setBaseToolTipGenerator(toolTipGenerator); plot.getRenderer(datasetIndex).setURLGenerator(urlGenerator); // GRID: // PROBLEM: JFreeChart only allows to switch the grid on/off // for the whole XYPlot. And the // grid will always be displayed for the first series in the // plot. I'll always show the // grid. // --> plot.setDomainGridlinesVisible(visible) // RANGE AXIS LABELS: if (isOverview) { plot.getRangeAxisForDataset(datasetIndex).setTickLabelsVisible(false); plot.getRangeAxisForDataset(datasetIndex).setTickMarksVisible(false); plot.getRangeAxisForDataset(datasetIndex).setVisible(false); } else { plot.getRangeAxisForDataset(datasetIndex).setLabelFont(label); plot.getRangeAxisForDataset(datasetIndex).setLabelPaint(LABEL_COLOR); plot.getRangeAxisForDataset(datasetIndex).setTickLabelFont(tickLabelDomain); plot.getRangeAxisForDataset(datasetIndex).setTickLabelPaint(LABEL_COLOR); StringBuilder unitOfMeasure = new StringBuilder(); unitOfMeasure.append(dd.getPhenomenon().getLabel()); String uomLabel = dd.getUomLabel(); if (uomLabel != null && !uomLabel.isEmpty()) { unitOfMeasure.append(" (").append(uomLabel).append(")"); } plot.getRangeAxisForDataset(datasetIndex).setLabel(unitOfMeasure.toString()); } } } } return chart; }
From source file:com.t3.macro.api.functions.input.ColumnPanel.java
/** Creates a label control, with optional icon. */ public JComponent createLabelControl(VarSpec vs) { boolean hasText = vs.optionValues.optionEquals("TEXT", "TRUE"); boolean hasIcon = vs.optionValues.optionEquals("ICON", "TRUE"); // If the string starts with "<html>" then Swing will consider it HTML... if (hasText && vs.value.matches("^\\s*<html>")) { // For HTML values we use a HTMLPane. HTMLPane htmlp = new HTMLPane(); htmlp.setText(vs.value);//from w w w . ja v a 2 s .c om htmlp.setBackground(Color.decode("0xECE9D8")); return htmlp; } UpdatingLabel label = new UpdatingLabel(); int iconSize = vs.optionValues.getNumeric("ICONSIZE", 0); if (iconSize <= 0) hasIcon = false; String valueText = "", assetID = ""; Icon icon = null; // See if the string has an image URL inside it Matcher matcher = ASSET_PATTERN.matcher(vs.value); if (matcher.find()) { valueText = matcher.group(1); assetID = matcher.group(2); } else { hasIcon = false; valueText = vs.value; } // Try to get the icon if (hasIcon) { icon = InputFunctions.getIcon(assetID, iconSize, label); if (icon == null) hasIcon = false; } // Assemble the label if (hasText) label.setText(valueText); if (hasIcon) label.setIcon(icon); return label; }