List of usage examples for java.text NumberFormat getNumberInstance
public static NumberFormat getNumberInstance(Locale inLocale)
From source file:desmoj.extensions.grafic.util.Plotter.java
/** * configure range axis ( lowerBound, upperBound, label, format ticks) * of time-series chart// ww w .j a v a 2 s . c o m * @param numberAxis * @param label */ private void configureRangeAxis(NumberAxis numberAxis, String label) { double min = numberAxis.getLowerBound(); double max = numberAxis.getUpperBound(); Double delta = 0.01 * (max - min); numberAxis.setLowerBound(min - delta); numberAxis.setUpperBound(max + delta); numberAxis.setLabel(label); // format Ticks double fontHeight = numberAxis.getTickLabelFont().getLineMetrics("X", this.frc).getHeight(); double maxTicks = this.paintPanel.getSize().height / fontHeight; int digits = Math.max(0, (int) -Math.floor(Math.log10((max - min) / maxTicks))); //System.out.println(fontHeight+" "+digits+" "+Math.log10((max - min)/ maxTicks)); NumberFormat formatter = NumberFormat.getNumberInstance(this.locale); formatter.setMinimumFractionDigits(digits); formatter.setMaximumFractionDigits(digits); formatter.setGroupingUsed(true); numberAxis.setNumberFormatOverride(formatter); }
From source file:org.opennms.netmgt.collectd.HttpCollector.java
private static List<HttpCollectionAttribute> processResponse(final Locale responseLocale, final String responseBodyAsString, final HttpCollectionSet collectionSet, HttpCollectionResource collectionResource) { LOG.debug("processResponse:"); LOG.debug("responseBody = {}", responseBodyAsString); LOG.debug("getmatches = {}", collectionSet.getUriDef().getUrl().getMatches()); List<HttpCollectionAttribute> butes = new LinkedList<HttpCollectionAttribute>(); int flags = 0; if (collectionSet.getUriDef().getUrl().getCanonicalEquivalence()) { flags |= Pattern.CANON_EQ; }// www .j a v a2 s .c o m if (collectionSet.getUriDef().getUrl().getCaseInsensitive()) { flags |= Pattern.CASE_INSENSITIVE; } if (collectionSet.getUriDef().getUrl().getComments()) { flags |= Pattern.COMMENTS; } if (collectionSet.getUriDef().getUrl().getDotall()) { flags |= Pattern.DOTALL; } if (collectionSet.getUriDef().getUrl().getLiteral()) { flags |= Pattern.LITERAL; } if (collectionSet.getUriDef().getUrl().getMultiline()) { flags |= Pattern.MULTILINE; } if (collectionSet.getUriDef().getUrl().getUnicodeCase()) { flags |= Pattern.UNICODE_CASE; } if (collectionSet.getUriDef().getUrl().getUnixLines()) { flags |= Pattern.UNIX_LINES; } LOG.debug("flags = {}", flags); Pattern p = Pattern.compile(collectionSet.getUriDef().getUrl().getMatches(), flags); Matcher m = p.matcher(responseBodyAsString); final boolean matches = m.matches(); if (matches) { LOG.debug("processResponse: found matching attributes: {}", matches); final List<Attrib> attribDefs = collectionSet.getUriDef().getAttributes().getAttribCollection(); final AttributeGroupType groupType = new AttributeGroupType(collectionSet.getUriDef().getName(), AttributeGroupType.IF_TYPE_ALL); final List<Locale> locales = new ArrayList<Locale>(); if (responseLocale != null) { locales.add(responseLocale); } locales.add(Locale.getDefault()); if (Locale.getDefault() != Locale.ENGLISH) { locales.add(Locale.ENGLISH); } for (final Attrib attribDef : attribDefs) { final String type = attribDef.getType(); String value = null; try { value = m.group(attribDef.getMatchGroup()); } catch (final IndexOutOfBoundsException e) { LOG.error( "IndexOutOfBoundsException thrown while trying to find regex group, your regex does not contain the following group index: {}", attribDef.getMatchGroup()); LOG.error("Regex statement: {}", collectionSet.getUriDef().getUrl().getMatches()); continue; } if (!type.matches("^([Oo](ctet|CTET)[Ss](tring|TRING))|([Ss](tring|TRING))$")) { Number num = null; for (final Locale locale : locales) { try { num = NumberFormat.getNumberInstance(locale).parse(value); LOG.debug("processResponse: found a parsable number with locale \"{}\".", locale); break; } catch (final ParseException e) { LOG.warn( "attribute {} failed to match a parsable number with locale \"{}\"! Matched \"{}\" instead.", attribDef.getAlias(), locale, value); } } if (num == null) { LOG.warn("processResponse: gave up attempting to parse numeric value, skipping group {}", attribDef.getMatchGroup()); continue; } final HttpCollectionAttribute bute = new HttpCollectionAttribute(collectionResource, new HttpCollectionAttributeType(attribDef, groupType), num); LOG.debug("processResponse: adding found numeric attribute: {}", bute); butes.add(bute); } else { HttpCollectionAttribute bute = new HttpCollectionAttribute(collectionResource, new HttpCollectionAttributeType(attribDef, groupType), value); LOG.debug("processResponse: adding found string attribute: {}", bute); butes.add(bute); } } } else { LOG.debug("processResponse: found matching attributes: {}", matches); } return butes; }
From source file:de.betterform.xml.xforms.ui.state.UIElementStateUtil.java
/** * localize a string value depending on datatype and locale * * @param owner the BindingElement which is localized * @param type the datatype of the bound Node * @param value the string value to convert * @return returns a localized representation of the input string *///from w w w . j a v a 2 s .co m public static String localiseValue(BindingElement owner, Element state, String type, String value) throws XFormsException { if (value == null || value.equals("")) { return value; } String tmpType = type; if (tmpType != null && tmpType.contains(":")) { tmpType = tmpType.substring(tmpType.indexOf(":") + 1, tmpType.length()); } if (Config.getInstance().getProperty(XFormsProcessorImpl.BETTERFORM_ENABLE_L10N, "true").equals("true")) { Locale locale = (Locale) owner.getModel().getContainer().getProcessor().getContext() .get(XFormsProcessorImpl.BETTERFORM_LOCALE); if (tmpType == null) { tmpType = owner.getModelItem().getDeclarationView().getDatatype(); } if (tmpType == null) { LOGGER.debug(DOMUtil.getCanonicalPath(owner.getInstanceNode()) + " has no type, assuming 'string'"); return value; } if (tmpType.equalsIgnoreCase("float") || tmpType.equalsIgnoreCase("decimal") || tmpType.equalsIgnoreCase("double")) { if (value.equals("")) return value; if (value.equals("NaN")) return value; //do not localize 'NaN' as it returns strange characters try { NumberFormat formatter = NumberFormat.getNumberInstance(locale); if (formatter instanceof DecimalFormat) { //get original number format int separatorPos = value.indexOf("."); if (separatorPos == -1) { formatter.setMaximumFractionDigits(0); } else { int fractionDigitCount = value.length() - separatorPos - 1; formatter.setMinimumFractionDigits(fractionDigitCount); } Double num = Double.parseDouble(value); return formatter.format(num.doubleValue()); } } catch (NumberFormatException e) { LOGGER.warn("Value '" + value + "' is no valid " + tmpType); return value; } } else if (tmpType.equalsIgnoreCase("date")) { SimpleDateFormat sf = new SimpleDateFormat("yyyy-MM-dd"); try { Date d = sf.parse(value); return DateFormat.getDateInstance(DateFormat.DEFAULT, locale).format(d); } catch (ParseException e) { LOGGER.warn("Value '" + value + "' is no valid " + tmpType); return value; } } else if (tmpType.equalsIgnoreCase("dateTime")) { //hackery due to lacking pattern for ISO 8601 Timezone representation in SimpleDateFormat String timezone = ""; String dateTime = null; if (value.contains("GMT")) { timezone = " GMT" + value.substring(value.lastIndexOf(":") - 3, value.length()); int devider = value.lastIndexOf(":"); dateTime = value.substring(0, devider) + value.substring(devider + 1, value.length()); } else if (value.contains("Z")) { timezone = ""; dateTime = value.substring(0, value.indexOf("Z")); } else if (value.contains("+")) { timezone = value.substring(value.indexOf("+"), value.length()); dateTime = value.substring(0, value.indexOf("+")); } else { dateTime = value; } SimpleDateFormat sf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss"); try { Date d = sf.parse(dateTime); return DateFormat.getDateTimeInstance(DateFormat.DEFAULT, DateFormat.DEFAULT, locale).format(d) + timezone; } catch (ParseException e) { LOGGER.warn("Value '" + value + "' is no valid " + tmpType); return value; } } else { //not logging for type 'string' if (LOGGER.isTraceEnabled() && !(tmpType.equals("string"))) { LOGGER.trace("Type " + tmpType + " cannot be localized"); } } } return value; }
From source file:edu.upb.winfo.downloadcom.DownloadComCrawler.java
/** * Handles the detailed product page and extracts version only details * using the above specified regular expression patterns and saves the * extracted content into the product version database * * @param pageContent The HTML source code of the given page *//*from ww w. ja v a 2 s. co m*/ protected void handleProductVersion(String pageContent) { int id_p = Integer.parseInt(RegEx.getMatch(PID, pageContent)); int vid = Integer.parseInt(RegEx.getMatch(VID, pageContent)); String version_name = RegEx.getMatch(VERSION_NAME, pageContent); String version_alterations = RegEx.getMatch(VERSION_ALTERATIONS, pageContent); Date version_publish_date = null; try { version_publish_date = DateParser.getDate(RegEx.getMatch(VERSION_PUBLISH_DATE, pageContent)); } catch (ParseException e) { e.printStackTrace(); } Date version_added_date = null; try { version_added_date = DateParser.getDate(RegEx.getMatch(VERSION_ADDED_DATE, pageContent)); } catch (ParseException e) { e.printStackTrace(); } String version_identifier = RegEx.getMatch(VERSION_IDENTIFIER, pageContent); String operating_systems = RegEx.getMatch(OPERATING_SYSTEMS, pageContent); String additional_requirements = RegEx.getMatch(ADDITIONAL_REQUIREMENTS, pageContent); String download_size = RegEx.getMatch(DOWNLOAD_SIZE, pageContent); String download_name = RegEx.getMatch(DOWNLOAD_NAME, pageContent); String download_link = RegEx.getMatch(DOWNLOAD_LINK, pageContent); int downloads_total = 0; try { downloads_total = NumberFormat.getNumberInstance(Locale.US) .parse(RegEx.getMatch(DOWNLOADS_TOTAL, pageContent)).intValue(); } catch (ParseException e) { e.printStackTrace(); } int downloads_last_week = 0; try { downloads_last_week = NumberFormat.getNumberInstance(Locale.US) .parse(RegEx.getMatch(DOWNLOADS_LAST_WEEK, pageContent)).intValue(); } catch (ParseException e) { e.printStackTrace(); } String license_model = RegEx.getMatch(LICENSE_MODEL, pageContent); String license_limitations = RegEx.getMatch(LICENSE_LIMITATIONS, pageContent); String license_cost = RegEx.getMatch(LICENSE_COST, pageContent); App.DATABASE.updateProductVersion(id_p, vid, version_name, version_alterations, version_publish_date, version_added_date, version_identifier, operating_systems, additional_requirements, download_size, download_name, download_link, downloads_total, downloads_last_week, license_model, license_limitations, license_cost); }
From source file:it.eng.spagobi.engines.chart.bo.charttypes.barcharts.StackedBarGroup.java
/** * Inherited by IChart./* w w w. ja v a 2s . c om*/ * * @param chartTitle the chart title * @param dataset the dataset * * @return the j free chart */ public JFreeChart createChart(DatasetMap datasets) { logger.debug("IN"); CategoryDataset dataset = (CategoryDataset) datasets.getDatasets().get("1"); logger.debug("Get plot orientaton"); PlotOrientation plotOrientation = PlotOrientation.VERTICAL; if (horizontalView) { plotOrientation = PlotOrientation.HORIZONTAL; } JFreeChart chart = ChartFactory.createStackedBarChart(name, // chart title categoryLabel, // domain axis label valueLabel, // range axis label dataset, // data plotOrientation, // the plot orientation legend, // legend true, // tooltips false // urls ); chart.setBackgroundPaint(Color.white); CategoryPlot plot = (CategoryPlot) chart.getPlot(); plot.setBackgroundPaint(color); plot.setRangeGridlinePaint(Color.white); plot.setDomainGridlinePaint(Color.white); plot.setDomainGridlinesVisible(true); GroupedStackedBarRenderer renderer = new GroupedStackedBarRenderer(); KeyToGroupMap map = new KeyToGroupMap("G1"); int numElForGroup = 0; for (int idx = 0; idx < numGroups.intValue(); idx++) { for (int j = 0; j < numSerieForGroup.intValue(); j++) { try { String tmpSubCat = (String) subCategoryNames.get(j + idx * numSerieForGroup.intValue()); map.mapKeyToGroup(tmpSubCat, "G" + (idx + 1)); } catch (Exception e) { logger.error("out of range error in inserting in stacked bar group: continue anayway", e); } } } renderer.setSeriesToGroupMap(map); renderer.setItemMargin(0.0); renderer.setDrawBarOutline(false); renderer.setBaseItemLabelsVisible(true); if (percentageValue) renderer.setBaseItemLabelGenerator( new StandardCategoryItemLabelGenerator("{2}", new DecimalFormat("#,##.#%"))); else renderer.setBaseItemLabelGenerator(new FilterZeroStandardCategoryItemLabelGenerator()); renderer.setToolTipGenerator(new StandardCategoryToolTipGenerator()); if (maxBarWidth != null) { renderer.setMaximumBarWidth(maxBarWidth.doubleValue()); } boolean document_composition = false; if (mode.equalsIgnoreCase(SpagoBIConstants.DOCUMENT_COMPOSITION)) document_composition = true; /* MyCategoryUrlGenerator mycatUrl=new MyCategoryUrlGenerator(rootUrl); mycatUrl.setDocument_composition(document_composition); mycatUrl.setCategoryUrlLabel(categoryUrlName); mycatUrl.setSerieUrlLabel(serieUrlname); renderer.setItemURLGenerator(mycatUrl); */ TextTitle title = setStyleTitle(name, styleTitle); chart.setTitle(title); if (subName != null && !subName.equals("")) { TextTitle subTitle = setStyleTitle(subName, styleSubTitle); chart.addSubtitle(subTitle); } // NOW DO SOME OPTIONAL CUSTOMISATION OF THE CHART... // set the background color for the chart... chart.setBackgroundPaint(color); NumberFormat nf = NumberFormat.getNumberInstance(locale); // set the range axis to display integers only... NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setLabelFont(new Font(styleXaxesLabels.getFontName(), Font.PLAIN, styleXaxesLabels.getSize())); rangeAxis.setLabelPaint(styleXaxesLabels.getColor()); rangeAxis .setTickLabelFont(new Font(styleXaxesLabels.getFontName(), Font.PLAIN, styleXaxesLabels.getSize())); rangeAxis.setTickLabelPaint(styleXaxesLabels.getColor()); rangeAxis.setNumberFormatOverride(nf); if (rangeIntegerValues == true) { rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); } if (rangeAxisLocation != null) { if (rangeAxisLocation.equalsIgnoreCase("BOTTOM_OR_LEFT")) { plot.setRangeAxisLocation(0, AxisLocation.BOTTOM_OR_LEFT); } else if (rangeAxisLocation.equalsIgnoreCase("BOTTOM_OR_RIGHT")) { plot.setRangeAxisLocation(0, AxisLocation.BOTTOM_OR_RIGHT); } else if (rangeAxisLocation.equalsIgnoreCase("TOP_OR_RIGHT")) { plot.setRangeAxisLocation(0, AxisLocation.TOP_OR_RIGHT); } else if (rangeAxisLocation.equalsIgnoreCase("TOP_OR_LEFT")) { plot.setRangeAxisLocation(0, AxisLocation.TOP_OR_LEFT); } } int seriesN = dataset.getRowCount(); int numSerieColored = 0; if (orderColorVector != null && orderColorVector.size() > 0) { logger.debug("color serie by SERIES_ORDER_COLORS template specification"); for (int i = 0; i < seriesN; i++) { if (orderColorVector.get(i) != null) { Color color = orderColorVector.get(i); renderer.setSeriesPaint(i, color); } } } else if (colorMap != null) { while (numSerieColored < seriesN) { for (int i = 1; i <= colorMap.size(); i++) { Color color = (Color) colorMap.get("SER" + i); Color gradient = new Color(Integer.decode("#FFFFFF").intValue()); if (gradientMap != null) gradient = (Color) gradientMap.get("SER" + i); if (color != null) { Paint p = new GradientPaint(0.0f, 0.0f, color, 0.0f, 0.0f, gradient); //renderer.setSeriesPaint(numSerieColored, color); renderer.setSeriesPaint(numSerieColored, p); } numSerieColored++; } } } renderer.setGradientPaintTransformer( new StandardGradientPaintTransformer(GradientPaintTransformType.HORIZONTAL)); MyStandardCategoryItemLabelGenerator generator = null; if (additionalLabels) { generator = new MyStandardCategoryItemLabelGenerator(catSerLabels, "{1}", NumberFormat.getInstance()); double orient = (-Math.PI / 2.0); if (styleValueLabels.getOrientation().equalsIgnoreCase("horizontal")) { orient = 0.0; } renderer.setBaseItemLabelFont( new Font(styleValueLabels.getFontName(), Font.PLAIN, styleValueLabels.getSize())); renderer.setBaseItemLabelPaint(styleValueLabels.getColor()); renderer.setBaseItemLabelGenerator(generator); renderer.setBaseItemLabelsVisible(true); //vertical labels renderer.setBasePositiveItemLabelPosition( new ItemLabelPosition(ItemLabelAnchor.CENTER, TextAnchor.CENTER, TextAnchor.CENTER, orient)); renderer.setBaseNegativeItemLabelPosition( new ItemLabelPosition(ItemLabelAnchor.CENTER, TextAnchor.CENTER, TextAnchor.CENTER, orient)); //horizontal labels /* renderer.setBasePositiveItemLabelPosition(new ItemLabelPosition( ItemLabelAnchor.CENTER, TextAnchor.CENTER)); renderer.setBaseNegativeItemLabelPosition(new ItemLabelPosition( ItemLabelAnchor.CENTER, TextAnchor.CENTER)); */ } SubCategoryAxis domainAxis = new SubCategoryAxis(categoryLabel + " / " + subCategoryLabel); String subCatLabel = ""; for (int j = 1; j <= numGroups.intValue(); j++) { if (subCatLabelsMap != null) subCatLabel = (String) subCatLabelsMap.get("CAT" + j); else subCatLabel = subCategoryLabel; domainAxis.addSubCategory(subCatLabel); domainAxis .setLabelFont(new Font(styleYaxesLabels.getFontName(), Font.PLAIN, styleYaxesLabels.getSize())); domainAxis.setLabelPaint(styleYaxesLabels.getColor()); domainAxis.setTickLabelFont( new Font(styleYaxesLabels.getFontName(), Font.PLAIN, styleYaxesLabels.getSize())); domainAxis.setTickLabelPaint(styleYaxesLabels.getColor()); } plot.setDomainAxis(domainAxis); plot.setRenderer(renderer); /* domainAxis.setCategoryLabelPositions( CategoryLabelPositions.createUpRotationLabelPositions( Math.PI / 6.0)); */ if (legend == true) drawLegend(chart); logger.debug("OUT"); return chart; }
From source file:com.mycompany.jpegrenamer.MetaDataReader.java
public Map<String, String> getMetaData(final File jpegImageFile) throws ImageProcessingException, IOException { Metadata metadata = ImageMetadataReader.readMetadata(jpegImageFile); Map<String, String> res = new HashMap<>(); res.put("date", "Pinding"); for (Directory directory : metadata.getDirectories()) { for (Tag tag : directory.getTags()) { logger.debug("{} - {} = {}", directory.getName(), tag.getTagName(), tag.getDescription()); }//from w ww . java2 s . c o m if (directory.hasErrors()) { for (String error : directory.getErrors()) { logger.debug("ERROR: {}", error); } } } // obtain the Exif directory ExifSubIFDDirectory directory = metadata.getFirstDirectoryOfType(ExifSubIFDDirectory.class); // query the tag's value if (directory == null) { return res; } PanasonicMakernoteDirectory pmd = metadata.getFirstDirectoryOfType(PanasonicMakernoteDirectory.class); if (pmd != null) { String country = ""; String city = ""; String landmark = ""; for (Tag tag : pmd.getTags()) { if (tag.getTagType() == PanasonicMakernoteDirectory.TAG_COUNTRY) { country = tag.getDescription(); if (!country.equals("---")) { res.put("country", country); } } else if (tag.getTagType() == PanasonicMakernoteDirectory.TAG_CITY) { city = tag.getDescription(); if (!city.equals("---")) { res.put("locality", city); } } else if (tag.getTagType() == PanasonicMakernoteDirectory.TAG_LANDMARK) { landmark = tag.getDescription(); if (!landmark.equals("---")) { res.put("premise", landmark); } } } logger.info("Panasonic fafa " + country + " x " + city + " x " + landmark); } Date dateOfCapture = directory.getDate(ExifSubIFDDirectory.TAG_DATETIME_ORIGINAL); final DateFormat df = new SimpleDateFormat("yyyy-MM-dd HH.mm.ss", Locale.ENGLISH); String s = null; if (dateOfCapture != null) { s = df.format(dateOfCapture); } else { return res; } logger.info("Date " + dateOfCapture.toString()); logger.info("Date f " + s); res.put("date", s); // if (res.get("country") != null) { // // We have some data from Panasonic Makernotes, so no need to lookup GPS // return res; // } // See whether it has GPS data Collection<GpsDirectory> gpsDirectories = metadata.getDirectoriesOfType(GpsDirectory.class); if (gpsDirectories == null) { return res; } for (GpsDirectory gpsDirectory : gpsDirectories) { // Try to read out the location, making sure it's non-zero GeoLocation geoLocation = gpsDirectory.getGeoLocation(); if (geoLocation != null && !geoLocation.isZero()) { // Add to our collection for use below logger.info("Geo " + geoLocation.toString()); double lat = geoLocation.getLatitude(); double lon = geoLocation.getLongitude(); Locale fmtLocale = Locale.US; NumberFormat formatter = NumberFormat.getNumberInstance(fmtLocale); formatter.setGroupingUsed(false); Map<String, String> location = new HashMap(); ; try { location = getAddressByGpsCoordinates(formatter.format(lat), formatter.format(lon)); logger.info("Location " + location); res.putAll(location); } catch (MalformedURLException ex) { logger.error("", ex); } catch (org.json.simple.parser.ParseException ex) { logger.error("", ex); } break; } } return res; }
From source file:org.archive.util.ArchiveUtils.java
public static String doubleToString(double val, int maxFractionDigits, int minFractionDigits) { // NumberFormat returns U+FFFD REPLACEMENT CHARACTER for NaN which looks // like a bug in the UI if (Double.isNaN(val)) { return "NaN"; }// w w w.j a v a 2 s. com NumberFormat f = NumberFormat.getNumberInstance(Locale.US); f.setMaximumFractionDigits(maxFractionDigits); f.setMinimumFractionDigits(minFractionDigits); return f.format(val); }
From source file:it.eng.spagobi.engines.chart.bo.charttypes.barcharts.CombinedCategoryBar.java
public JFreeChart createChart(DatasetMap datasets) { logger.debug("IN"); // recover the datasets DefaultCategoryDataset datasetBarFirstAxis = (DefaultCategoryDataset) datasets.getDatasets().get("1-bar"); DefaultCategoryDataset datasetBarSecondAxis = (DefaultCategoryDataset) datasets.getDatasets().get("2-bar"); DefaultCategoryDataset datasetLineFirstAxis = (DefaultCategoryDataset) datasets.getDatasets().get("1-line"); DefaultCategoryDataset datasetLineSecondAxis = (DefaultCategoryDataset) datasets.getDatasets() .get("2-line"); // create the two subplots CategoryPlot subPlot1 = new CategoryPlot(); CategoryPlot subPlot2 = new CategoryPlot(); CombinedDomainCategoryPlot plot = new CombinedDomainCategoryPlot(); subPlot1.setDataset(0, datasetBarFirstAxis); subPlot2.setDataset(0, datasetBarSecondAxis); subPlot1.setDataset(1, datasetLineFirstAxis); subPlot2.setDataset(1, datasetLineSecondAxis); // localize numbers on y axis NumberFormat nf = (NumberFormat) NumberFormat.getNumberInstance(locale); // Range Axis 1 NumberAxis rangeAxis = new NumberAxis(getValueLabel()); rangeAxis.setLabelFont(new Font(styleXaxesLabels.getFontName(), Font.PLAIN, styleXaxesLabels.getSize())); rangeAxis.setLabelPaint(styleXaxesLabels.getColor()); rangeAxis/*from w w w. ja v a2 s . co m*/ .setTickLabelFont(new Font(styleXaxesLabels.getFontName(), Font.PLAIN, styleXaxesLabels.getSize())); rangeAxis.setTickLabelPaint(styleXaxesLabels.getColor()); rangeAxis.setUpperMargin(0.10); rangeAxis.setNumberFormatOverride(nf); subPlot1.setRangeAxis(rangeAxis); if (rangeIntegerValues == true) { rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); } // Range Axis 2 NumberAxis rangeAxis2 = new NumberAxis(secondAxisLabel); rangeAxis2.setLabelFont(new Font(styleXaxesLabels.getFontName(), Font.PLAIN, styleXaxesLabels.getSize())); rangeAxis2.setLabelPaint(styleXaxesLabels.getColor()); rangeAxis2 .setTickLabelFont(new Font(styleXaxesLabels.getFontName(), Font.PLAIN, styleXaxesLabels.getSize())); rangeAxis2.setTickLabelPaint(styleXaxesLabels.getColor()); rangeAxis2.setUpperMargin(0.10); rangeAxis2.setNumberFormatOverride(nf); subPlot2.setRangeAxis(rangeAxis2); if (rangeIntegerValues == true) { rangeAxis2.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); } // Category Axis CategoryAxis domainAxis = new CategoryAxis(getCategoryLabel()); domainAxis.setLabelFont(new Font(styleYaxesLabels.getFontName(), Font.PLAIN, styleYaxesLabels.getSize())); domainAxis.setLabelPaint(styleYaxesLabels.getColor()); domainAxis .setTickLabelFont(new Font(styleYaxesLabels.getFontName(), Font.PLAIN, styleYaxesLabels.getSize())); domainAxis.setTickLabelPaint(styleYaxesLabels.getColor()); domainAxis.setUpperMargin(0.10); plot.setDomainAxis(domainAxis); plot.setOrientation(PlotOrientation.VERTICAL); plot.setRangeGridlinesVisible(true); plot.setDomainGridlinesVisible(true); // Add subplots to main plot plot.add(subPlot1, 1); plot.add(subPlot2, 2); MyStandardCategoryItemLabelGenerator generator = null; // value labels and additional values are mutually exclusive if (showValueLabels == true) additionalLabels = false; if (additionalLabels) { generator = new MyStandardCategoryItemLabelGenerator(catSerLabels, "{1}", NumberFormat.getInstance()); } // Create Renderers! CategoryItemRenderer barRenderer1 = new BarRenderer(); CategoryItemRenderer barRenderer2 = new BarRenderer(); LineAndShapeRenderer lineRenderer1 = (useLinesRenderers == true) ? new LineAndShapeRenderer() : null; LineAndShapeRenderer lineRenderer2 = (useLinesRenderers == true) ? new LineAndShapeRenderer() : null; subPlot1.setRenderer(0, barRenderer1); subPlot2.setRenderer(0, barRenderer2); if (useLinesRenderers == true) { subPlot1.setRenderer(1, lineRenderer1); subPlot2.setRenderer(1, lineRenderer2); // no shapes for line_no_shapes series for (Iterator iterator = lineNoShapeSeries1.iterator(); iterator.hasNext();) { String ser = (String) iterator.next(); // if there iS a abel associated search for that String label = null; if (seriesLabelsMap != null) { label = (String) seriesLabelsMap.get(ser); } if (label == null) label = ser; int index = datasetLineFirstAxis.getRowIndex(label); if (index != -1) { lineRenderer1.setSeriesShapesVisible(index, false); } } for (Iterator iterator = lineNoShapeSeries2.iterator(); iterator.hasNext();) { String ser = (String) iterator.next(); // if there iS a abel associated search for that String label = null; if (seriesLabelsMap != null) { label = (String) seriesLabelsMap.get(ser); } if (label == null) label = ser; int index = datasetLineSecondAxis.getRowIndex(label); if (index != -1) { lineRenderer2.setSeriesShapesVisible(index, false); } } } // add tooltip if enabled if (enableToolTips) { MyCategoryToolTipGenerator generatorToolTip = new MyCategoryToolTipGenerator(freeToolTips, seriesTooltip, categoriesTooltip, seriesCaptions); barRenderer1.setToolTipGenerator(generatorToolTip); barRenderer2.setToolTipGenerator(generatorToolTip); if (useLinesRenderers) { lineRenderer1.setToolTipGenerator(generatorToolTip); lineRenderer2.setToolTipGenerator(generatorToolTip); } } subPlot1.setDatasetRenderingOrder(DatasetRenderingOrder.FORWARD); subPlot2.setDatasetRenderingOrder(DatasetRenderingOrder.FORWARD); // COnfigure renderers: I do in extensive way so will be easier to add customization in the future if (maxBarWidth != null) { ((BarRenderer) barRenderer1).setMaximumBarWidth(maxBarWidth.doubleValue()); ((BarRenderer) barRenderer2).setMaximumBarWidth(maxBarWidth.doubleValue()); } // Values or addition Labels for first BAR Renderer if (showValueLabels) { barRenderer1.setBaseItemLabelGenerator(new FilterZeroStandardCategoryItemLabelGenerator()); barRenderer1.setBaseItemLabelsVisible(true); barRenderer1.setBaseItemLabelFont( new Font(styleValueLabels.getFontName(), Font.PLAIN, styleValueLabels.getSize())); barRenderer1.setBaseItemLabelPaint(styleValueLabels.getColor()); barRenderer1.setBasePositiveItemLabelPosition( new ItemLabelPosition(ItemLabelAnchor.OUTSIDE12, TextAnchor.BASELINE_LEFT)); barRenderer1.setBaseNegativeItemLabelPosition( new ItemLabelPosition(ItemLabelAnchor.OUTSIDE12, TextAnchor.BASELINE_LEFT)); barRenderer2.setBaseItemLabelGenerator(new FilterZeroStandardCategoryItemLabelGenerator()); barRenderer2.setBaseItemLabelsVisible(true); barRenderer2.setBaseItemLabelFont( new Font(styleValueLabels.getFontName(), Font.PLAIN, styleValueLabels.getSize())); barRenderer2.setBaseItemLabelPaint(styleValueLabels.getColor()); barRenderer2.setBasePositiveItemLabelPosition( new ItemLabelPosition(ItemLabelAnchor.OUTSIDE12, TextAnchor.BASELINE_LEFT)); barRenderer2.setBaseNegativeItemLabelPosition( new ItemLabelPosition(ItemLabelAnchor.OUTSIDE12, TextAnchor.BASELINE_LEFT)); } else if (additionalLabels) { barRenderer1.setBaseItemLabelGenerator(generator); barRenderer2.setBaseItemLabelGenerator(generator); double orient = (-Math.PI / 2.0); if (styleValueLabels.getOrientation().equalsIgnoreCase("horizontal")) { orient = 0.0; } barRenderer1.setBasePositiveItemLabelPosition( new ItemLabelPosition(ItemLabelAnchor.CENTER, TextAnchor.CENTER, TextAnchor.CENTER, orient)); barRenderer1.setBaseNegativeItemLabelPosition( new ItemLabelPosition(ItemLabelAnchor.CENTER, TextAnchor.CENTER, TextAnchor.CENTER, orient)); barRenderer2.setBasePositiveItemLabelPosition( new ItemLabelPosition(ItemLabelAnchor.CENTER, TextAnchor.CENTER, TextAnchor.CENTER, orient)); barRenderer2.setBaseNegativeItemLabelPosition( new ItemLabelPosition(ItemLabelAnchor.CENTER, TextAnchor.CENTER, TextAnchor.CENTER, orient)); } // Values or addition Labels for line Renderers if requested if (useLinesRenderers == true) { if (showValueLabels) { lineRenderer1.setBaseItemLabelGenerator(new FilterZeroStandardCategoryItemLabelGenerator()); lineRenderer1.setBaseItemLabelsVisible(true); lineRenderer1.setBaseItemLabelFont( new Font(styleValueLabels.getFontName(), Font.PLAIN, styleValueLabels.getSize())); lineRenderer1.setBaseItemLabelPaint(styleValueLabels.getColor()); lineRenderer1.setBasePositiveItemLabelPosition( new ItemLabelPosition(ItemLabelAnchor.OUTSIDE12, TextAnchor.BASELINE_LEFT)); lineRenderer1.setBaseNegativeItemLabelPosition( new ItemLabelPosition(ItemLabelAnchor.OUTSIDE12, TextAnchor.BASELINE_LEFT)); lineRenderer2.setBaseItemLabelGenerator(new FilterZeroStandardCategoryItemLabelGenerator()); lineRenderer2.setBaseItemLabelsVisible(true); lineRenderer2.setBaseItemLabelFont( new Font(styleValueLabels.getFontName(), Font.PLAIN, styleValueLabels.getSize())); lineRenderer2.setBaseItemLabelPaint(styleValueLabels.getColor()); lineRenderer2.setBasePositiveItemLabelPosition( new ItemLabelPosition(ItemLabelAnchor.OUTSIDE12, TextAnchor.BASELINE_LEFT)); lineRenderer2.setBaseNegativeItemLabelPosition( new ItemLabelPosition(ItemLabelAnchor.OUTSIDE12, TextAnchor.BASELINE_LEFT)); } else if (additionalLabels) { lineRenderer1.setBaseItemLabelGenerator(generator); lineRenderer2.setBaseItemLabelGenerator(generator); double orient = (-Math.PI / 2.0); if (styleValueLabels.getOrientation().equalsIgnoreCase("horizontal")) { orient = 0.0; } lineRenderer1.setBasePositiveItemLabelPosition(new ItemLabelPosition(ItemLabelAnchor.CENTER, TextAnchor.CENTER, TextAnchor.CENTER, orient)); lineRenderer1.setBaseNegativeItemLabelPosition(new ItemLabelPosition(ItemLabelAnchor.CENTER, TextAnchor.CENTER, TextAnchor.CENTER, orient)); lineRenderer2.setBasePositiveItemLabelPosition(new ItemLabelPosition(ItemLabelAnchor.CENTER, TextAnchor.CENTER, TextAnchor.CENTER, orient)); lineRenderer2.setBaseNegativeItemLabelPosition(new ItemLabelPosition(ItemLabelAnchor.CENTER, TextAnchor.CENTER, TextAnchor.CENTER, orient)); } } // Bar Dataset Colors! if (colorMap != null) { int idx = -1; for (Iterator iterator = datasetBarFirstAxis.getRowKeys().iterator(); iterator.hasNext();) { idx++; String serName = (String) iterator.next(); String labelName = ""; int index = -1; if (seriesCaptions != null && seriesCaptions.size() > 0) { labelName = serName; serName = (String) seriesCaptions.get(serName); index = datasetBarFirstAxis.getRowIndex(labelName); } else index = datasetBarFirstAxis.getRowIndex(serName); Color color = (Color) colorMap.get(serName); if (color != null) { barRenderer1.setSeriesPaint(index, color); } } for (Iterator iterator = datasetBarSecondAxis.getRowKeys().iterator(); iterator.hasNext();) { idx++; String serName = (String) iterator.next(); String labelName = ""; int index = -1; if (seriesCaptions != null && seriesCaptions.size() > 0) { labelName = serName; serName = (String) seriesCaptions.get(serName); index = datasetBarSecondAxis.getRowIndex(labelName); } else index = datasetBarSecondAxis.getRowIndex(serName); Color color = (Color) colorMap.get(serName); if (color != null) { barRenderer2.setSeriesPaint(index, color); } } } // LINE Dataset Colors! if (useLinesRenderers == true) { if (colorMap != null) { int idx = -1; for (Iterator iterator = datasetLineFirstAxis.getRowKeys().iterator(); iterator.hasNext();) { idx++; String serName = (String) iterator.next(); String labelName = ""; int index = -1; if (seriesCaptions != null && seriesCaptions.size() > 0) { labelName = serName; serName = (String) seriesCaptions.get(serName); index = datasetLineFirstAxis.getRowIndex(labelName); } else index = datasetLineFirstAxis.getRowIndex(serName); Color color = (Color) colorMap.get(serName); if (color != null) { lineRenderer1.setSeriesPaint(index, color); } } for (Iterator iterator = datasetLineSecondAxis.getRowKeys().iterator(); iterator.hasNext();) { idx++; String serName = (String) iterator.next(); String labelName = ""; int index = -1; if (seriesCaptions != null && seriesCaptions.size() > 0) { labelName = serName; serName = (String) seriesCaptions.get(serName); index = datasetLineSecondAxis.getRowIndex(labelName); } else index = datasetLineSecondAxis.getRowIndex(serName); Color color = (Color) colorMap.get(serName); if (color != null) { lineRenderer2.setSeriesPaint(index, color); } } } } //defines url for drill boolean document_composition = false; if (mode.equalsIgnoreCase(SpagoBIConstants.DOCUMENT_COMPOSITION)) document_composition = true; logger.debug("Calling Url Generation"); MyCategoryUrlGenerator mycatUrl = null; if (super.rootUrl != null) { logger.debug("Set MycatUrl"); mycatUrl = new MyCategoryUrlGenerator(super.rootUrl); mycatUrl.setDocument_composition(document_composition); mycatUrl.setCategoryUrlLabel(super.categoryUrlName); mycatUrl.setSerieUrlLabel(super.serieUrlname); mycatUrl.setDrillDocTitle(drillDocTitle); mycatUrl.setTarget(target); } if (mycatUrl != null) { barRenderer1.setItemURLGenerator(mycatUrl); barRenderer2.setItemURLGenerator(mycatUrl); if (useLinesRenderers) { lineRenderer1.setItemURLGenerator(mycatUrl); lineRenderer2.setItemURLGenerator(mycatUrl); } } plot.getDomainAxis().setCategoryLabelPositions(CategoryLabelPositions.UP_45); JFreeChart chart = new JFreeChart(plot); TextTitle title = setStyleTitle(name, styleTitle); chart.setTitle(title); if (subName != null && !subName.equals("")) { TextTitle subTitle = setStyleTitle(subName, styleSubTitle); chart.addSubtitle(subTitle); } chart.setBackgroundPaint(Color.white); // I want to re order the legend LegendItemCollection legends = plot.getLegendItems(); // legend Temp HashMap<String, LegendItem> legendTemp = new HashMap<String, LegendItem>(); Vector<String> alreadyInserted = new Vector<String>(); for (int i = 0; i < legends.getItemCount(); i++) { LegendItem item = legends.get(i); String label = item.getLabel(); legendTemp.put(label, item); } LegendItemCollection newLegend = new LegendItemCollection(); // force the order of the ones specified for (Iterator iterator = seriesOrder.iterator(); iterator.hasNext();) { String serie = (String) iterator.next(); if (legendTemp.keySet().contains(serie)) { newLegend.add(legendTemp.get(serie)); alreadyInserted.add(serie); } } // check that there are no serie not specified, otherwise add them for (Iterator iterator = legendTemp.keySet().iterator(); iterator.hasNext();) { String serie = (String) iterator.next(); if (!alreadyInserted.contains(serie)) { newLegend.add(legendTemp.get(serie)); } } plot.setFixedLegendItems(newLegend); if (legend == true) drawLegend(chart); logger.debug("OUT"); return chart; }
From source file:com.webbfontaine.valuewebb.model.util.Utils.java
public static String getAsString(Number number, String pattern) { if (number == null) { return ""; }/*from w w w.ja va 2s. co m*/ DecimalFormat decimalFormat = (DecimalFormat) NumberFormat .getNumberInstance(LocaleSelector.instance().getLocale()); decimalFormat.applyPattern(pattern); return decimalFormat.format(number); }
From source file:it.eng.spagobi.engines.chart.bo.charttypes.barcharts.StackedBar.java
/** * Inherited by IChart.//from ww w. j a v a 2 s .co m * * @param chartTitle the chart title * @param dataset the dataset * * @return the j free chart */ public JFreeChart createChart(DatasetMap datasets) { logger.debug("IN"); CategoryDataset dataset = (CategoryDataset) datasets.getDatasets().get("1"); logger.debug("Taken Dataset"); logger.debug("Get plot orientaton"); PlotOrientation plotOrientation = PlotOrientation.VERTICAL; if (horizontalView) { plotOrientation = PlotOrientation.HORIZONTAL; } logger.debug("Call Chart Creation"); JFreeChart chart = ChartFactory.createStackedBarChart(name, // chart title categoryLabel, // domain axis label valueLabel, // range axis label dataset, // data plotOrientation, // the plot orientation false, // legend true, // tooltips false // urls ); logger.debug("Chart Created"); chart.setBackgroundPaint(Color.white); CategoryPlot plot = (CategoryPlot) chart.getPlot(); plot.setBackgroundPaint(color); plot.setRangeGridlinePaint(Color.white); plot.setDomainGridlinePaint(Color.white); plot.setDomainGridlinesVisible(true); logger.debug("set renderer"); StackedBarRenderer renderer = (StackedBarRenderer) plot.getRenderer(); renderer.setDrawBarOutline(false); renderer.setBaseItemLabelsVisible(true); if (percentageValue) renderer.setBaseItemLabelGenerator( new StandardCategoryItemLabelGenerator("{2}", new DecimalFormat("#,##.#%"))); else if (makePercentage) renderer.setRenderAsPercentages(true); /* else renderer.setBaseItemLabelGenerator(new StandardCategoryItemLabelGenerator()); */ renderer.setToolTipGenerator(new StandardCategoryToolTipGenerator()); if (maxBarWidth != null) { renderer.setMaximumBarWidth(maxBarWidth.doubleValue()); } boolean document_composition = false; if (mode.equalsIgnoreCase(SpagoBIConstants.DOCUMENT_COMPOSITION)) document_composition = true; logger.debug("Calling Url Generation"); MyCategoryUrlGenerator mycatUrl = null; if (rootUrl != null) { logger.debug("Set MycatUrl"); mycatUrl = new MyCategoryUrlGenerator(rootUrl); mycatUrl.setDocument_composition(document_composition); mycatUrl.setCategoryUrlLabel(categoryUrlName); mycatUrl.setSerieUrlLabel(serieUrlname); } if (mycatUrl != null) renderer.setItemURLGenerator(mycatUrl); logger.debug("Text Title"); TextTitle title = setStyleTitle(name, styleTitle); chart.setTitle(title); if (subName != null && !subName.equals("")) { TextTitle subTitle = setStyleTitle(subName, styleSubTitle); chart.addSubtitle(subTitle); } logger.debug("Style Labels"); Color colorSubInvisibleTitle = Color.decode("#FFFFFF"); StyleLabel styleSubSubTitle = new StyleLabel("Arial", 12, colorSubInvisibleTitle); TextTitle subsubTitle = setStyleTitle("", styleSubSubTitle); chart.addSubtitle(subsubTitle); // NOW DO SOME OPTIONAL CUSTOMISATION OF THE CHART... // set the background color for the chart... chart.setBackgroundPaint(color); logger.debug("Axis creation"); // set the range axis to display integers only... NumberFormat nf = NumberFormat.getNumberInstance(locale); NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); if (makePercentage) rangeAxis.setNumberFormatOverride(NumberFormat.getPercentInstance()); else rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); if (rangeIntegerValues == true) { rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); } rangeAxis.setLabelFont(new Font(styleXaxesLabels.getFontName(), Font.PLAIN, styleXaxesLabels.getSize())); rangeAxis.setLabelPaint(styleXaxesLabels.getColor()); rangeAxis .setTickLabelFont(new Font(styleXaxesLabels.getFontName(), Font.PLAIN, styleXaxesLabels.getSize())); rangeAxis.setTickLabelPaint(styleXaxesLabels.getColor()); rangeAxis.setNumberFormatOverride(nf); if (rangeAxisLocation != null) { if (rangeAxisLocation.equalsIgnoreCase("BOTTOM_OR_LEFT")) { plot.setRangeAxisLocation(0, AxisLocation.BOTTOM_OR_LEFT); } else if (rangeAxisLocation.equalsIgnoreCase("BOTTOM_OR_RIGHT")) { plot.setRangeAxisLocation(0, AxisLocation.BOTTOM_OR_RIGHT); } else if (rangeAxisLocation.equalsIgnoreCase("TOP_OR_RIGHT")) { plot.setRangeAxisLocation(0, AxisLocation.TOP_OR_RIGHT); } else if (rangeAxisLocation.equalsIgnoreCase("TOP_OR_LEFT")) { plot.setRangeAxisLocation(0, AxisLocation.TOP_OR_LEFT); } } renderer.setDrawBarOutline(false); logger.debug("Set series color"); int seriesN = dataset.getRowCount(); if (orderColorVector != null && orderColorVector.size() > 0) { logger.debug("color serie by SERIES_ORDER_COLORS template specification"); for (int i = 0; i < seriesN; i++) { if (orderColorVector.get(i) != null) { Color color = orderColorVector.get(i); renderer.setSeriesPaint(i, color); } } } else if (colorMap != null) { for (int i = 0; i < seriesN; i++) { String serieName = (String) dataset.getRowKey(i); // if serie has been rinominated I must search with the new name! String nameToSearchWith = (seriesLabelsMap != null && seriesLabelsMap.containsKey(serieName)) ? seriesLabelsMap.get(serieName).toString() : serieName; Color color = (Color) colorMap.get(nameToSearchWith); if (color != null) { renderer.setSeriesPaint(i, color); renderer.setSeriesItemLabelFont(i, new Font(styleValueLabels.getFontName(), Font.PLAIN, styleValueLabels.getSize())); } } } logger.debug("If cumulative set series paint " + cumulative); if (cumulative) { int row = dataset.getRowIndex("CUMULATIVE"); if (row != -1) { if (color != null) renderer.setSeriesPaint(row, color); else renderer.setSeriesPaint(row, Color.WHITE); } } MyStandardCategoryItemLabelGenerator generator = null; logger.debug("Are there addition labels " + additionalLabels); logger.debug("Are there value labels " + showValueLabels); if (showValueLabels) { renderer.setBaseItemLabelGenerator(new FilterZeroStandardCategoryItemLabelGenerator()); renderer.setBaseItemLabelsVisible(true); renderer.setBaseItemLabelFont( new Font(styleValueLabels.getFontName(), Font.PLAIN, styleValueLabels.getSize())); renderer.setBaseItemLabelPaint(styleValueLabels.getColor()); if (valueLabelsPosition.equalsIgnoreCase("inside")) { renderer.setBasePositiveItemLabelPosition( new ItemLabelPosition(ItemLabelAnchor.CENTER, TextAnchor.BASELINE_LEFT)); renderer.setBaseNegativeItemLabelPosition( new ItemLabelPosition(ItemLabelAnchor.CENTER, TextAnchor.BASELINE_LEFT)); } else { renderer.setBasePositiveItemLabelPosition( new ItemLabelPosition(ItemLabelAnchor.OUTSIDE3, TextAnchor.BASELINE_LEFT)); renderer.setBaseNegativeItemLabelPosition( new ItemLabelPosition(ItemLabelAnchor.OUTSIDE3, TextAnchor.BASELINE_LEFT)); } } else if (additionalLabels) { generator = new MyStandardCategoryItemLabelGenerator(catSerLabels, "{1}", NumberFormat.getInstance()); logger.debug("generator set"); double orient = (-Math.PI / 2.0); logger.debug("add labels style"); if (styleValueLabels.getOrientation() != null && styleValueLabels.getOrientation().equalsIgnoreCase("horizontal")) { orient = 0.0; } renderer.setBaseItemLabelFont( new Font(styleValueLabels.getFontName(), Font.PLAIN, styleValueLabels.getSize())); renderer.setBaseItemLabelPaint(styleValueLabels.getColor()); logger.debug("add labels style set"); renderer.setBaseItemLabelGenerator(generator); renderer.setBaseItemLabelsVisible(true); //vertical labels renderer.setBasePositiveItemLabelPosition( new ItemLabelPosition(ItemLabelAnchor.OUTSIDE12, TextAnchor.CENTER, TextAnchor.CENTER, orient)); renderer.setBaseNegativeItemLabelPosition( new ItemLabelPosition(ItemLabelAnchor.OUTSIDE12, TextAnchor.CENTER, TextAnchor.CENTER, orient)); logger.debug("end of add labels "); } logger.debug("domain axis"); CategoryAxis domainAxis = plot.getDomainAxis(); domainAxis.setCategoryLabelPositions(CategoryLabelPositions.createUpRotationLabelPositions(Math.PI / 4.0)); domainAxis.setLabelFont(new Font(styleYaxesLabels.getFontName(), Font.PLAIN, styleYaxesLabels.getSize())); domainAxis.setLabelPaint(styleYaxesLabels.getColor()); domainAxis .setTickLabelFont(new Font(styleYaxesLabels.getFontName(), Font.PLAIN, styleYaxesLabels.getSize())); domainAxis.setTickLabelPaint(styleYaxesLabels.getColor()); //opacizzazione colori if (!cumulative) plot.setForegroundAlpha(0.6f); if (legend == true) drawLegend(chart); logger.debug("OUT"); return chart; }