List of usage examples for java.awt Font CENTER_BASELINE
int CENTER_BASELINE
To view the source code for java.awt Font CENTER_BASELINE.
Click Source Link
From source file:org.foxbpm.engine.impl.diagramview.svg.builder.AbstractSVGBuilder.java
public void setTextFont(String fontStr) { if (StringUtils.isBlank(fontStr)) { Font font = new Font(ARIAL, Font.CENTER_BASELINE, 11); this.textVO.setFont(font); return;/*from w w w. ja v a2 s . com*/ } String[] fonts = fontStr.split(COMMA); String style = new StringBuffer("font-family:").append(fonts[0]).append(";font-size:").append(fonts[1]) .toString(); Font font = new Font(fonts[0], Font.PLAIN, Integer.valueOf(fonts[1])); this.textVO.setFont(font); this.textVO.setStyle(style); this.textVO.setFontSize(fonts[1]); }
From source file:org.cyberoam.iview.charts.CustomCategoryDataset.java
/** * This method generates JFreeChart instance for 3D Stacked Column chart with iView customization. * @param reportID specifies that for which report Chart is being prepared. * @param rsw specifies data set which would be used for the Chart * @param requeest used for Hyperlink generation from uri. * @return jfreechart instance with iView Customization. *//*w w w . j av a2s.co m*/ public static JFreeChart getChart(int reportId, ResultSetWrapper rsw, HttpServletRequest request) { ReportBean reportBean = ReportBean.getRecordbyPrimarykey(reportId); JFreeChart chart = null; try { /* * Create data set based on rsw object. */ ReportColumnBean reportColumnBean = null; GraphBean graphBean = null; DataLinkBean dataLinkBean = null; CustomCategoryDataset dataset = new CustomCategoryDataset(); graphBean = GraphBean.getRecordbyPrimarykey(reportBean.getGraphId());//Getting GraphBean reportColumnBean = ReportColumnBean.getRecordByPrimaryKey(reportBean.getReportId(), graphBean.getXColumnId());//getting ReportColumnBean For X Axis String xColumnDBname = reportColumnBean.getDbColumnName(); reportColumnBean.getColumnName(); //Wheather DataLink is Given For X Axis column if (reportColumnBean.getDataLinkId() != -1) { dataLinkBean = DataLinkBean.getRecordbyPrimarykey(reportColumnBean.getDataLinkId()); } reportColumnBean = ReportColumnBean.getRecordByPrimaryKey(reportBean.getReportId(), graphBean.getYColumnId()); String yColumnDBname = reportColumnBean.getDbColumnName(); reportColumnBean.getColumnName(); //if DataLink is not Given For X Axis column then Check of Y Axis Column if (dataLinkBean == null && reportColumnBean.getDataLinkId() != -1) { dataLinkBean = DataLinkBean.getRecordbyPrimarykey(reportColumnBean.getDataLinkId()); } reportColumnBean = ReportColumnBean.getRecordByPrimaryKey(reportBean.getReportId(), graphBean.getZColumnId()); //String zColumnDbname = reportColumnBean.getDbColumnName(); String xData = null, zData = null; //Preparing DataSet rsw.beforeFirst(); while (rsw.next()) { xData = rsw.getString(xColumnDBname); //zData = rsw.getString(zColumnDbname); zData = TabularReportGenerator.getFormattedColumn(reportColumnBean.getColumnFormat(), reportColumnBean.getDbColumnName(), rsw); if (xData == null || "".equalsIgnoreCase(xData) || "null".equalsIgnoreCase(xData)) xData = "N/A"; dataset.addValue(new Long(rsw.getLong(yColumnDBname)), zData, xData, rsw.getString("deviceid")); } //Create the jfree chart instance. chart = ChartFactory.createStackedBarChart3D("", // chart title "", "", dataset, // data PlotOrientation.VERTICAL, true, // include legend true, // tooltips? false // URLs? ); /* *Setting additional customization to the chart. */ //Set the background color for the chart... chart.setBackgroundPaint(Color.white); //Get a reference to the plot for further customisation... CategoryPlot plot = chart.getCategoryPlot(); plot.setBackgroundPaint(new Color(245, 245, 245)); plot.setDomainGridlinePaint(Color.white); plot.setDomainGridlinesVisible(true); plot.setRangeGridlinePaint(Color.LIGHT_GRAY); //Set the range axis to display integers only... NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); reportColumnBean = ReportColumnBean.getRecordByPrimaryKey(reportBean.getReportId(), graphBean.getYColumnId()); if (reportColumnBean.getColumnFormat() == TabularReportConstants.BYTE_FORMATTING) { rangeAxis.setTickUnit(new ByteTickUnit(rangeAxis.getUpperBound() / 4)); } rangeAxis.setStandardTickUnits(NumberAxis.createStandardTickUnits()); rangeAxis.setTickLabelFont(new Font("Vandara", Font.CENTER_BASELINE, 10)); rangeAxis.setTickLabelsVisible(true); rangeAxis.setTickMarksVisible(false); rangeAxis.setAxisLineVisible(false); Axis domainAxis = plot.getDomainAxis(); domainAxis.setTickLabelFont(new Font("Vandara", Font.CENTER_BASELINE, 10)); domainAxis.setTickMarksVisible(false); domainAxis.setAxisLineVisible(false); LegendTitle legendTitle = chart.getLegend(); legendTitle.setItemFont(new Font("Arial", Font.CENTER_BASELINE, 11)); BarRenderer renderer = (BarRenderer) plot.getRenderer(); renderer.setDrawBarOutline(false); renderer.setMaximumBarWidth(0.05); renderer.setSeriesPaint(0, new Color(24, 112, 176)); renderer.setSeriesPaint(1, new Color(168, 192, 232)); renderer.setSeriesPaint(2, new Color(248, 120, 8)); renderer.setSeriesPaint(3, new Color(248, 184, 120)); renderer.setSeriesPaint(4, new Color(152, 216, 136)); if (dataLinkBean != null && request != null) { renderer.setBaseItemURLGenerator(new CustomURLGeneratorForStackedChart( dataLinkBean.generateURLForChart(request), "", "deviceid")); } renderer.setBaseToolTipGenerator(new CustomToolTipGeneratorForStacked()); } catch (Exception e) { CyberoamLogger.appLog.debug("StackedColumn3D.e:" + e, e); } return chart; }
From source file:lol.search.RankedStatsPage.java
private JPanel headerPanel() { //init spacers for header for (int i = 0; i < 10; i++) { JLabel label = new JLabel("--"); label.setForeground(new Color(0, 0, 0, 0)); spacers.add(label);//from w w w . j a v a 2s .c o m } //header -- to set this semi-transparent i had to remove setOpaque and replace with setBackground(...) JPanel headerPanel = new JPanel(); headerPanel.setLayout(new BorderLayout()); //headerPanel.setBorder(BorderFactory.createLineBorder(Color.WHITE)); headerPanel.setBackground(backgroundColor); headerPanel.setPreferredSize(headerDimension); //back button JPanel buttonHolder = new JPanel(); ImageIcon buttonImage = new ImageIcon("assets\\other\\button.png"); ImageIcon buttonPressedImage = new ImageIcon("assets\\other\\buttonPressed.png"); Image tempImage = buttonImage.getImage(); Image newTempImg = tempImage.getScaledInstance(75, 35, Image.SCALE_SMOOTH); buttonImage = new ImageIcon(newTempImg); JButton backButton = new JButton("BACK"); backButton.setFont(new Font("Sen-Regular", Font.CENTER_BASELINE, 10)); //custom font backButton.setForeground(Color.WHITE); //text color backButton.setBackground(new Color(0, 0, 0, 0)); backButton.setBorder(BorderFactory.createLineBorder(Color.BLACK)); backButton.setHorizontalTextPosition(AbstractButton.CENTER); backButton.setPreferredSize(new Dimension(75, 35)); //pressed button Image tempImage2 = buttonPressedImage.getImage(); Image newTempImg2 = tempImage2.getScaledInstance(75, 35, Image.SCALE_SMOOTH); buttonPressedImage = new ImageIcon(newTempImg2); backButton.setIcon(buttonImage); backButton.setRolloverIcon(buttonPressedImage); backButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { //button pressed System.out.println("Going back...\n"); masterFrame.getContentPane().removeAll(); masterFrame.revalidate(); masterFrame.repaint(); MainPage MAIN_PAGE = new MainPage(masterFrame, summonerName); } }); buttonHolder.add(backButton); buttonHolder.setOpaque(false); headerPanel.add(buttonHolder, BorderLayout.LINE_START); //centerpanel JPanel centerPanel = new JPanel(); centerPanel.setLayout(new GridLayout(1, 2)); centerPanel.setOpaque(false); //centerPanel.setBorder(BorderFactory.createLineBorder(Color.WHITE)); //rightcenter JPanel rightCenter = new JPanel(); rightCenter.setOpaque(false); rightCenter.setLayout(new GridLayout(2, 1)); //top center panel JPanel topCenter = new JPanel(); topCenter.setOpaque(false); topCenter.setLayout(new BoxLayout(topCenter, BoxLayout.X_AXIS)); //profile icon JPanel proIconPanel = new JPanel(); proIconPanel.setOpaque(false); proIconPanel.setLayout(new BoxLayout(proIconPanel, BoxLayout.Y_AXIS)); JLabel profileIconLabel = new JLabel(this.profileIcon); //profileIconLabel.setBorder(BorderFactory.createLineBorder(Color.WHITE)); profileIconLabel.setAlignmentX(Component.RIGHT_ALIGNMENT); proIconPanel.add(profileIconLabel); centerPanel.add(proIconPanel); //empty spacer topCenter.add(spacers.get(0)); //summoner name JLabel summonerNameLabel = new JLabel(this.summonerName); summonerNameLabel.setFont(new Font("Sen-Regular", Font.CENTER_BASELINE, 15)); //custom font summonerNameLabel.setForeground(Color.WHITE); //text color summonerNameLabel.setAlignmentX(Component.LEFT_ALIGNMENT); topCenter.add(summonerNameLabel); //empty spacer topCenter.add(spacers.get(1)); //tier JLabel tierLabel = new JLabel(this.tier); tierLabel.setFont(new Font("Sen-Regular", Font.CENTER_BASELINE, 13)); //custom font tierLabel.setForeground(new Color(219, 219, 219)); //text color tierLabel.setAlignmentX(Component.LEFT_ALIGNMENT); topCenter.add(tierLabel); //empty spacer topCenter.add(spacers.get(2)); //division JLabel divisionLabel = new JLabel(this.division); divisionLabel.setFont(new Font("Sen-Regular", Font.CENTER_BASELINE, 13)); //custom font divisionLabel.setForeground(new Color(219, 219, 219)); //text color divisionLabel.setAlignmentX(Component.LEFT_ALIGNMENT); topCenter.add(divisionLabel); //bottom center panel JPanel bottomCenter = new JPanel(); bottomCenter.setOpaque(false); bottomCenter.setLayout(new BoxLayout(bottomCenter, BoxLayout.X_AXIS)); //empty spacer bottomCenter.add(spacers.get(3)); //season JLabel winsLabel = new JLabel(this.season); winsLabel.setFont(new Font("Sen-Regular", Font.CENTER_BASELINE, 14)); //custom font winsLabel.setForeground(new Color(219, 219, 219)); //text color winsLabel.setAlignmentX(Component.LEFT_ALIGNMENT); bottomCenter.add(winsLabel); rightCenter.add(topCenter); rightCenter.add(bottomCenter); centerPanel.add(rightCenter); headerPanel.add(centerPanel, BorderLayout.CENTER); //empty panel to balance right side JPanel ee = new JPanel(); ee.setOpaque(false); ee.setPreferredSize(new Dimension(260, 50)); headerPanel.add(ee, BorderLayout.LINE_END); return headerPanel; }
From source file:org.cyberoam.iview.charts.CustomCategoryAxis.java
/** * This method generates JFreeChart instance for 3D Bar chart with iView customization. * @param reportID specifies that for which report Chart is being prepared. * @param rsw specifies data set which would be used for the Chart * @param requeest used for Hyperlink generation from uri. * @return jfreechart instance with iView Customization. *//*from ww w . jav a 2 s . co m*/ public static JFreeChart getChart(int reportID, ResultSetWrapper rsw, HttpServletRequest request) { JFreeChart chart = null; boolean isPDF = false; try { if (request == null) { isPDF = true; } /* * Create data set based on rsw object. */ ReportBean reportBean = ReportBean.getRecordbyPrimarykey(reportID); ReportColumnBean reportColumnBeanX, reportColumnBeanY = null; GraphBean graphBean = null; DataLinkBean dataLinkBean = null; DefaultCategoryDataset dataset = new DefaultCategoryDataset(); graphBean = GraphBean.getRecordbyPrimarykey(reportBean.getGraphId());//Getting GraphBean reportColumnBeanX = ReportColumnBean.getRecordByPrimaryKey(reportBean.getReportId(), graphBean.getXColumnId());//getting ReportColumnBean For X Axis if (reportColumnBeanX.getDataLinkId() != -1) { dataLinkBean = DataLinkBean.getRecordbyPrimarykey(reportColumnBeanX.getDataLinkId()); } reportColumnBeanY = ReportColumnBean.getRecordByPrimaryKey(reportBean.getReportId(), graphBean.getYColumnId()); rsw.beforeFirst(); int i = 0; DecimalFormat placeHolder = new DecimalFormat("00"); String xData = null; String graphurl = ""; HashMap<Integer, String> urlmap = new HashMap<Integer, String>(); while (rsw.next()) { xData = rsw.getString(reportColumnBeanX.getDbColumnName()); if (dataLinkBean != null && request != null) { //datalink id is non -1 in tblcolumnreport table means another report is avaialble so set url // here multiple url possible bec multiple record so take hashmap and store url. // we have dataset but dataset is occupied. graphurl = dataLinkBean.generateURLForChart(rsw, request); urlmap.put(new Integer(i), graphurl); } //dataset second arugument use for bar line of graph and third argument give name of graph dataset.addValue(new Long(rsw.getLong(reportColumnBeanY.getDbColumnName())), "", placeHolder.format(i) + xData); i++; } // we define object of CustomURLGeneratorForBarChart and if datalinkid is not -1 then it object define for link CustomURLGeneratorForBarChart customURLGeneratorForBarChart = null; if (dataLinkBean != null && request != null) { customURLGeneratorForBarChart = new CustomURLGeneratorForBarChart( dataLinkBean.generateURLForChart(request), reportColumnBeanX.getDbColumnName()); customURLGeneratorForBarChart.setUrlMap(urlmap); } /* * Create the jfree chart object. */ String title = isPDF ? reportBean.getTitle() : ""; chart = ChartFactory.createBarChart3D(title, // chart title "", // domain axis label "", dataset, // data PlotOrientation.HORIZONTAL, // orientation false, // include legend true, // tooltips? false // URLs? ); /* *Setting additional customization to the chart. */ //Set background color chart.setBackgroundPaint(Color.white); //Get a reference to the plot for further customisation CategoryPlot plot = chart.getCategoryPlot(); plot.setBackgroundPaint(Color.white); plot.setDomainGridlinePaint(Color.white); plot.setDomainGridlinesVisible(true); plot.setRangeGridlinePaint(Color.DARK_GRAY); plot.setForegroundAlpha(0.8f); plot.setDomainGridlineStroke(new BasicStroke(2)); plot.setOutlineVisible(false); plot.setRangeAxisLocation(AxisLocation.BOTTOM_OR_RIGHT); //Set the range axis to display integers only... NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); if (reportColumnBeanY.getColumnFormat() == TabularReportConstants.BYTE_FORMATTING) { rangeAxis.setTickUnit(new ByteTickUnit(rangeAxis.getUpperBound() / 4)); } rangeAxis.setStandardTickUnits(NumberAxis.createStandardTickUnits()); rangeAxis.setTickLabelFont(new Font("Arial", Font.CENTER_BASELINE, 10)); rangeAxis.setTickLabelsVisible(true); rangeAxis.setTickMarksVisible(true); rangeAxis.setAxisLineVisible(false); rangeAxis.setLabel(reportColumnBeanY.getColumnName()); rangeAxis.setLabelFont(new Font("Arial", Font.CENTER_BASELINE, 12)); rangeAxis.setLabelPaint(new Color(35, 139, 199)); CustomCategoryAxis catAxis = new CustomCategoryAxis(); catAxis.setTickLabelFont(new Font("Arial", Font.CENTER_BASELINE, 10)); catAxis.setTickMarksVisible(false); catAxis.setAxisLineVisible(false); catAxis.setLabel(reportColumnBeanX.getColumnName()); catAxis.setLabelFont(new Font("Arial", Font.CENTER_BASELINE, 12)); catAxis.setLabelPaint(new Color(35, 139, 199)); catAxis.setLabelFormat(reportColumnBeanX.getColumnFormat()); plot.setDomainAxis(catAxis); //Set custom color for the chart. CategoryItemRenderer renderer = new CustomRenderer(new Paint[] { new Color(254, 211, 41), new Color(243, 149, 80), new Color(199, 85, 82), new Color(181, 105, 152), new Color(69, 153, 204), new Color(155, 212, 242), new Color(52, 172, 100), new Color(164, 212, 92), new Color(177, 155, 138), new Color(149, 166, 141) }); plot.setRenderer(renderer); BarRenderer renderer2 = (BarRenderer) plot.getRenderer(); renderer2.setDrawBarOutline(false); renderer2.setBaseItemLabelsVisible(true); renderer2.setMaximumBarWidth(0.04); if (dataLinkBean != null && request != null) { renderer.setBaseItemURLGenerator(customURLGeneratorForBarChart); //renderer.setBaseItemURLGenerator(new CustomURLGeneratorForBarChart(dataLinkBean.generateURLForChart(request),reportColumnBeanX.getDbColumnName())); } renderer.setBaseToolTipGenerator(new CustomToolTipGenerator()); renderer.setBaseToolTipGenerator(new CustomToolTipGenerator()); renderer.setBaseToolTipGenerator( new CustomToolTipGenerator("{2} " + reportColumnBeanY.getColumnName())); } catch (Exception e) { CyberoamLogger.appLog.debug("Bar3D.e:" + e, e); } return chart; }
From source file:lol.search.RankedStatsPage.java
private JPanel bodyPanel(JPanel body) { body.setLayout(new BoxLayout(body, BoxLayout.X_AXIS)); body.setBackground(backgroundColor); body.setPreferredSize(new Dimension(1200, 530)); //load art //w w w. jav a 2 s . co m this.loadArtLabel.setAlignmentX(Component.LEFT_ALIGNMENT); this.loadArtLabel.setPreferredSize(new Dimension(290, 504)); this.loadArtLabel.setIcon(OBJ_GAME_STATIC_DATA.initLoadingArt(champKeyList.get(0))); body.add(this.loadArtLabel); JPanel rightPanel = new JPanel(new FlowLayout()); rightPanel.setPreferredSize(new Dimension(800, 514)); rightPanel.setOpaque(false); //rightPanel.setBorder(BorderFactory.createLineBorder(Color.DARK_GRAY)); JPanel headerPanel = new JPanel(); headerPanel.setLayout(new BoxLayout(headerPanel, BoxLayout.X_AXIS)); headerPanel.setPreferredSize(new Dimension(910, 55)); headerPanel.setOpaque(false); //headerPanel.setBorder(BorderFactory.createLineBorder(Color.DARK_GRAY)); this.defaultHeader.setFont(new Font("Sen-Regular", Font.CENTER_BASELINE, 40)); //custom font this.defaultHeader.setForeground(Color.WHITE); this.defaultHeader.setAlignmentX(Component.LEFT_ALIGNMENT); this.defaultHeader.setText(" Season Totals: "); this.nameHeader.setFont(new Font("Sen-Regular", Font.CENTER_BASELINE, 40)); //custom font this.nameHeader.setForeground(valueOrange); this.nameHeader.setAlignmentX(Component.LEFT_ALIGNMENT); this.nameHeader.setText("Overall"); this.titleHeader.setFont(new Font("Sen-Regular", Font.CENTER_BASELINE, 16)); //custom font this.titleHeader.setForeground(new Color(255, 128, 0)); this.titleHeader.setAlignmentX(Component.LEFT_ALIGNMENT); //nameHeader.setAlignmentY(Component.TOP_ALIGNMENT); titleHeader.setAlignmentY(Component.TOP_ALIGNMENT); headerPanel.add(defaultHeader); headerPanel.add(nameHeader); headerPanel.add(titleHeader); rightPanel.add(headerPanel); rightPanel.add(statsPanel()); body.add(rightPanel); return body; }
From source file:lol.search.RankedStatsPage.java
private void totalJLabel(JLabel label, String text, Color color) { label.setText(text);/* w ww .j a va 2 s .co m*/ label.setForeground(color); label.setFont(new Font("Sen-Regular", Font.CENTER_BASELINE, 16)); //custom font }
From source file:knop.psfj.BeadImage.java
/** * Gets the montage.// w w w. j a va2s. c om * * @return the montage */ public ImageProcessor getMontage() { int beadPerCorner = 4; int beadNumber = getBeadFrameList().getWithAlterEgo().size(); if (beadNumber < 4 * 9 * 2) { beadPerCorner = 1; } if (beadNumber < 18) { return getBeadFrameList().getValidBeadFrames().getBeadMontage(); } int enlargementFactor = 3; int cornerWidth = MathUtils.round(Math.sqrt(beadPerCorner)) * getBeadFrame(0).getWidth() * enlargementFactor; int cornerHeight = MathUtils.round(Math.sqrt(beadPerCorner)) * getBeadFrame(0).getHeight() * enlargementFactor; int mw = cornerWidth * 3; int mh = cornerHeight * 3; ColorProcessor finalMontage = new ColorProcessor(mw, mh); for (int x = -1; x != 2; x++) { for (int y = -1; y != 2; y++) { int xf = (x + 1) * cornerWidth; int yf = (y + 1) * cornerHeight; ImageProcessor beadMontage = getBeadFrameList().getWithAlterEgo() .getSampleFromCorner(getZone(x, y, 4), beadPerCorner).getBeadMontage(); beadMontage = beadMontage.resize(beadMontage.getWidth() * enlargementFactor, beadMontage.getHeight() * enlargementFactor, true); finalMontage.copyBits(beadMontage, xf, yf, Blitter.COPY); finalMontage.setColor(Color.white.darker().darker()); finalMontage.setFont(new Font(java.awt.Font.SANS_SERIF, java.awt.Font.CENTER_BASELINE, 10)); finalMontage.drawString(getCornerName(x, y), xf + 5, yf + 16); finalMontage.setColor(Color.yellow.darker()); finalMontage.drawRect((x + 1) * cornerWidth, (y + 1) * cornerHeight, cornerWidth, cornerHeight); } } return finalMontage; }