List of usage examples for java.awt Font PLAIN
int PLAIN
To view the source code for java.awt Font PLAIN.
Click Source Link
From source file:ShowString.java
ShowString(String target, String title) { setTitle(title);/*from ww w.j a v a2 s . c o m*/ outString = target; Font font = new Font("Monospaced", Font.PLAIN, 36); fontM = getFontMetrics(font); setFont(font); int size = 0; for (int i = 0; i < outString.length(); i++) { size += fontM.charWidth(outString.charAt(i)); } size += 24; setSize(size, fontM.getHeight() + 60); setLocation(getSize().width / 2, getSize().height / 2); setVisible(true); }
From source file:cn.edu.thss.iise.bpmdemo.charts.SWTPieChartDemo1.java
/** * Creates a chart./* ww w . j a va 2 s . co m*/ * * @param dataset * the dataset. * * @return A chart. */ private static JFreeChart createChart(PieDataset dataset) { JFreeChart chart = ChartFactory.createPieChart("Pie Chart Demo 1", // chart // title dataset, // data true, // include legend true, false); PiePlot plot = (PiePlot) chart.getPlot(); plot.setSectionOutlinesVisible(false); plot.setLabelFont(new Font("SansSerif", Font.PLAIN, 12)); plot.setNoDataMessage("No data available"); plot.setCircular(false); plot.setLabelGap(0.02); return chart; }
From source file:com.uniteddev.Unity.Login.java
public static void setup() throws IOException, InterruptedException, FontFormatException { //fonts//from www. j av a2s. co m roboto_thin = Font.createFont(Font.TRUETYPE_FONT, Unity.class.getResourceAsStream("/res/Roboto-Thin.ttf")); roboto_regular = Font.createFont(Font.TRUETYPE_FONT, Unity.class.getResourceAsStream("/res/Roboto-Regular.ttf")); // main window = new Window(Unity.title, Unity.favicon, Unity.background, 791, 527); release = new Label(Unity.release, Color.WHITE, roboto_regular.deriveFont(Font.PLAIN, 12)); server_lbl = new Label("Server:", Color.WHITE, roboto_regular.deriveFont(Font.PLAIN, 12)); server_stat_lbl = new Label("Offline", Color.RED, roboto_regular.deriveFont(Font.PLAIN, 12)); settingsButton = new Button(); settingsButton.setImage("/res/gear.png"); settingsButton.removeDecorations(); settingsButton.addActionListener(new settingsButton_action()); // splash screen update_lbl = new Label("Updating", Color.WHITE, roboto_thin.deriveFont(Font.PLAIN, 32)); progress = new ProgressBar(new Color(255, 255, 255, 100), new Color(255, 255, 255, 255)); progress.removeDecorations(); progressText = new Label("Ready.", Color.WHITE, roboto_regular.deriveFont(Font.PLAIN, 14)); // login screen username = new TextField(prefs.get("username", ""), Color.WHITE, roboto_regular.deriveFont(Font.PLAIN, 14)); password = new PasswordField(Color.WHITE, roboto_regular.deriveFont(Font.PLAIN, 14)); username_lbl = new Label("Username:", Color.WHITE, roboto_regular.deriveFont(Font.PLAIN, 14)); password_lbl = new Label("Password:", Color.WHITE, roboto_regular.deriveFont(Font.PLAIN, 14)); loginButton = new Button("Login", Color.WHITE, roboto_thin.deriveFont(Font.PLAIN, 28)); loginButton.setBorder(BorderFactory.createLineBorder(Color.WHITE, 1)); loginButton.center(); loginButton.addActionListener(new loginButton_action()); invalid_login_lbl = new Label("Invalid Login", Color.RED, roboto_regular.deriveFont(Font.PLAIN, 14)); invalid_login_lbl.setVisible(false); // settings screen settings_lbl = new Label("Settings", Color.WHITE, roboto_thin.deriveFont(Font.PLAIN, 32)); deleteButton = new Button(); deleteButton.setImage("/res/recycle.png"); deleteButton.removeDecorations(); deleteButton.addActionListener(new deleteButton_action()); ram_size = new TextField(prefs.get("ram_size", default_ram), Color.WHITE, roboto_regular.deriveFont(Font.PLAIN, 14)); ram_lbl = new Label("RAM Usage (MB):", Color.WHITE, roboto_regular.deriveFont(Font.PLAIN, 14)); invalid_ram_lbl = new Label(Color.RED, roboto_regular.deriveFont(Font.PLAIN, 14)); invalid_ram_lbl.setVisible(false); saveButton = new Button("Save", Color.WHITE, roboto_thin.deriveFont(Font.PLAIN, 28)); saveButton.setBorder(BorderFactory.createLineBorder(Color.WHITE, 1)); saveButton.center(); saveButton.addActionListener(new saveButton_action()); // sizing and layout release.setBounds(5, window.getHeight() - 50, 140, 20); server_lbl.setBounds(5, window.getHeight() - 50, 140, 20); server_stat_lbl.setBounds(45, window.getHeight() - 50, 200, 20); update_lbl.setBounds(115, 20, 320, 50); progress.setBounds(20, 75, 320, 10); progressText.setBounds(20, 90, 320, 20); username.setBounds(155, 30, 115, 20); password.setBounds(155, 60, 115, 20); username_lbl.setBounds(80, 30, 115, 20); password_lbl.setBounds(79, 60, 115, 20); loginButton.setBounds(110, 110, 140, 40); invalid_login_lbl.setBounds(135, 165, 140, 20); settingsButton.setBounds(window.getWidth() - 45, window.getHeight() - 65, 32, 32); settings_lbl.setBounds(115, 5, 320, 50); deleteButton.setBounds(155, 50, 32, 32); ram_size.setBounds(175, 90, 115, 20); ram_lbl.setBounds(60, 90, 115, 20); saveButton.setBounds(110, 125, 140, 40); // setup screens login_window = new Label(); login_window.setBounds(216, 180, 360, 200); login_window.add(update_lbl); login_window.add(progress); login_window.add(progressText); login_window.add(username); login_window.add(password); login_window.add(username_lbl); login_window.add(password_lbl); login_window.add(loginButton); login_window.add(invalid_login_lbl); login_window.add(settings_lbl); login_window.add(deleteButton); login_window.add(ram_size); login_window.add(invalid_ram_lbl); login_window.add(ram_lbl); login_window.add(saveButton); // setup and show window window.addComponent(release); window.addComponent(server_lbl); window.addComponent(server_stat_lbl); window.addComponent(login_window); window.addComponent(settingsButton); window.getRootPane().setDefaultButton(loginButton); window.setLocationRelativeTo(null); release.setVisible(false); window.setVisible(true); start(); }
From source file:FileViewer.java
/** * The real constructor. Create a FileViewer object to display the specified * file from the specified directory//w w w . java2s . c om */ public FileViewer(String directory, String filename) { super(); // Create the frame // Destroy the window when the user requests it addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { dispose(); } }); // Create a TextArea to display the contents of the file in textarea = new TextArea("", 24, 80); textarea.setFont(new Font("MonoSpaced", Font.PLAIN, 12)); textarea.setEditable(false); this.add("Center", textarea); // Create a bottom panel to hold a couple of buttons in Panel p = new Panel(); p.setLayout(new FlowLayout(FlowLayout.RIGHT, 10, 5)); this.add(p, "South"); // Create the buttons and arrange to handle button clicks Font font = new Font("SansSerif", Font.BOLD, 14); Button openfile = new Button("Open File"); Button close = new Button("Close"); openfile.addActionListener(this); openfile.setActionCommand("open"); openfile.setFont(font); close.addActionListener(this); close.setActionCommand("close"); close.setFont(font); p.add(openfile); p.add(close); this.pack(); // Figure out the directory, from filename or current dir, if necessary if (directory == null) { File f; if ((filename != null) && (f = new File(filename)).isAbsolute()) { directory = f.getParent(); filename = f.getName(); } else directory = System.getProperty("user.dir"); } this.directory = directory; // Remember the directory, for FileDialog setFile(directory, filename); // Now load and display the file }
From source file:com.orsonpdf.demo.PDFTimeSeriesChartDemo1.java
/** * Creates a chart.// ww w .j a va2 s. c o m * * @param dataset a dataset. * * @return A chart. */ private static JFreeChart createChart(XYDataset dataset) { JFreeChart chart = ChartFactory.createTimeSeriesChart("International Coffee Organisation : Coffee Prices", null, "US cents/lb", dataset, true, false, false); String fontName = "Palatino"; chart.getTitle().setFont(new Font(fontName, Font.BOLD, 18)); chart.addSubtitle(new TextTitle("Source: http://www.ico.org/historical/2010-19/PDF/HIST-PRICES.pdf", new Font(fontName, Font.PLAIN, 14))); XYPlot plot = (XYPlot) chart.getPlot(); plot.setDomainPannable(true); plot.setRangePannable(false); plot.setDomainCrosshairVisible(true); plot.setRangeCrosshairVisible(true); plot.getDomainAxis().setLowerMargin(0.0); plot.getDomainAxis().setLabelFont(new Font(fontName, Font.BOLD, 14)); plot.getDomainAxis().setTickLabelFont(new Font(fontName, Font.PLAIN, 12)); plot.getRangeAxis().setLabelFont(new Font(fontName, Font.BOLD, 14)); plot.getRangeAxis().setTickLabelFont(new Font(fontName, Font.PLAIN, 12)); plot.setRangeGridlinePaint(Color.red); plot.setDomainGridlinePaint(Color.red); chart.getLegend().setItemFont(new Font(fontName, Font.PLAIN, 14)); chart.getLegend().setFrame(BlockBorder.NONE); chart.getLegend().setHorizontalAlignment(HorizontalAlignment.CENTER); XYItemRenderer r = plot.getRenderer(); if (r instanceof XYLineAndShapeRenderer) { XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) r; renderer.setBaseShapesVisible(false); renderer.setDrawSeriesLineAsPath(true); // set the default stroke for all series renderer.setAutoPopulateSeriesStroke(false); renderer.setBaseStroke(new BasicStroke(3.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_BEVEL), false); renderer.setSeriesPaint(0, Color.RED); renderer.setSeriesPaint(1, new Color(24, 123, 58)); renderer.setSeriesPaint(2, new Color(149, 201, 136)); renderer.setSeriesPaint(3, new Color(1, 62, 29)); renderer.setSeriesPaint(4, new Color(81, 176, 86)); renderer.setSeriesPaint(5, new Color(0, 55, 122)); renderer.setSeriesPaint(6, new Color(0, 92, 165)); } return chart; }
From source file:costumetrade.common.verify.ImageVerification.java
public Pair<String, BufferedImage> create() { int x = 0, fontHeight = 0, codeY = 0; int red = 0, green = 0, blue = 0; x = width / (codeCount + 2);//? fontHeight = height - 2;// codeY = height - 4;//ww w .j av a2 s . co m // ?buffer BufferedImage buffImg = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB); Graphics2D g = buffImg.createGraphics(); // ? g.setColor(Color.WHITE); g.fillRect(0, 0, width, height); // g.setFont(new Font("Arial", Font.PLAIN, fontHeight)); for (int i = 0; i < lineCount; i++) { int xs = RandomUtils.nextInt(0, width); int ys = RandomUtils.nextInt(0, height); int xe = xs + RandomUtils.nextInt(0, width / 8); int ye = ys + RandomUtils.nextInt(0, height / 8); red = RandomUtils.nextInt(0, 255); green = RandomUtils.nextInt(0, 255); blue = RandomUtils.nextInt(0, 255); g.setColor(new Color(red, green, blue)); g.drawLine(xs, ys, xe, ye); } // randomCode??? StringBuilder randomCode = new StringBuilder(); // ?codeCount?? for (int i = 0; i < codeCount; i++) { String strRand = String.valueOf(codeSequence[RandomUtils.nextInt(0, codeSequence.length)]); // ???? red = RandomUtils.nextInt(0, 255); green = RandomUtils.nextInt(0, 255); blue = RandomUtils.nextInt(0, 255); g.setColor(new Color(red, green, blue)); g.drawString(strRand, (i + 1) * x, codeY); // ?? randomCode.append(strRand); } // ????Session return new Pair<String, BufferedImage>(randomCode.toString(), buffImg); }
From source file:com.bwc.ora.views.LabelPopupMenu.java
private void initMenu() { //determine if the point clicked already has an annotation boolean hasAnnotationAlready = hasAnnoationAlready(); if (hasAnnotationAlready) { //add label to allow users to deselect the label for a given peak JMenuItem nonItem = new JMenuItem("Remove Label"); nonItem.addActionListener(e -> { removeAnnotation();//from w w w . ja va 2s . com lrp.setAnnotations(LrpDisplayFrame.getInstance().getAnnotations()); }); add(nonItem); } //add list of possible labels for a point to the popup menu Arrays.stream(RetinalBand.values()).map(RetinalBand::toString).map(label -> { XYPointerAnnotation pointer = new XYPointerAnnotation(label, item.getDataset().getXValue(item.getSeriesIndex(), item.getItem()), item.getDataset().getYValue(item.getSeriesIndex(), item.getItem()), 0); pointer.setBaseRadius(35.0); pointer.setTipRadius(10.0); pointer.setFont(new Font("SansSerif", Font.PLAIN, 9)); pointer.setPaint(Color.blue); pointer.setTextAnchor(TextAnchor.CENTER_LEFT); JMenuItem l = new JMenuItem(label); l.addActionListener(e -> { if (hasAnnotationAlready) { removeAnnotation(); } chartPanel.getChart().getXYPlot().addAnnotation(pointer); lrp.setAnnotations(LrpDisplayFrame.getInstance().getAnnotations()); }); return l; }).forEach(this::add); }
From source file:org.jfree.eastwood.ChartApplet.java
/** * Starts the applet.// w ww .j av a 2 s .c om */ public void start() { String chartSpec = getParameter("chart"); try { Map params = Parameters.parseQueryString(chartSpec); JFreeChart chart = ChartEngine.buildChart(params, new Font("Dialog", Font.PLAIN, 12)); this.chartPanel.setChart(chart); } catch (UnsupportedEncodingException e) { e.printStackTrace(); } }
From source file:com.tencent.wstt.apt.chart.PieChart.java
private JFreeChart createChart() { this.dataset = new DefaultPieDataset(); final JFreeChart chart = ChartFactory.createPieChart("??", this.dataset, true, true, false); chart.getTitle().setFont(new Font("", Font.BOLD, 20)); PiePlot plot = (PiePlot) chart.getPlot(); plot.setLabelGenerator(new StandardPieSectionLabelGenerator("{0}:{1}")); plot.setLabelFont(new Font("SansSerif", Font.PLAIN, 12)); plot.setNoDataMessage("No data available"); plot.setCircular(false);// w w w.j av a2s . c om plot.setLabelGap(0.02); return chart; }
From source file:edu.wpi.cs.wpisuitetng.modules.requirementsmanager.view.charts.StatView.java
/** * Creates a chart.//from w ww. j a va2s . c o m * * @param dataset * the dataset. * * @return A chart. */ private static JFreeChart createPieStatusChart() { final StatusRequirementStatistics statusRequirementStatistics = new StatusRequirementStatistics(); final JFreeChart chart = statusRequirementStatistics.buildPieChart(); final PiePlot plot = (PiePlot) chart.getPlot(); plot.setLabelFont(new Font("SansSerif", Font.PLAIN, 12)); plot.setNoDataMessage("No data available"); plot.setCircular(true); plot.setLabelGap(0.02); return chart; }