List of usage examples for java.awt Label Label
public Label(String text) throws HeadlessException
From source file:D1WaveletTransform.java
@Test public void test() throws InterruptedException, JWaveException { CategoryTableXYDataset serie = new CategoryTableXYDataset(); serie.setNotify(false);//from w ww . j a v a 2s .c om double step = 1.0 / discretization; double startPosition = step * framePosition; //100 ? - 100 , 50 ? - 50 , 25 ?- 25 WaveletTransform t = new FastWaveletTransform((new Haar1())); double[] data = t.forward(testData.get1DSimpleSignal(1, 3, frameWidth, discretization), 128); // double[] data = math.convolve(testData.get1DSignal(100, 200, frameWidth, discretization), math.lpf(70, step, 128)); // double[] data = math.convolve(testData.get1DSignal(100, 200, 32768, 10000), math.lpf(70, 1./10000, 32)); // double[] data = testData.get1DSignal(100, 200, frameWidth, discretization); // double[] data = math.lpf(70, step,128); for (int i = 0; i < data.length; i++) { serie.add(startPosition, data[i], ""); startPosition += step; } JFreeChart chart = ChartFactory.createXYLineChart("", "t,c", "wave", serie); chart.removeLegend(); chart.setAntiAlias(false); XYPlot plot = chart.getXYPlot(); //plot.setRangeGridlinePaint(Color.BLACK); org.jfree.chart.axis.ValueAxis yAxis = plot.getRangeAxis(); org.jfree.chart.axis.ValueAxis xAxis = plot.getDomainAxis(); double start = framePosition * 1.0 / discretization; double max = start + frameWidth * 1.0 / discretization; xAxis.setRange(start, max); ChartPanel chartPanel = new ChartPanel(chart); JPanel p = new JPanel(new BorderLayout()); p.removeAll(); p.add(chartPanel); p.validate(); //1. Create the frame. JFrame frame = new JFrame("FrameDemo"); //2. Optional: What happens when the frame closes? frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); //3. Create components and put them in the frame. //...create emptyLabel... frame.getContentPane().add(new Label("olol"), BorderLayout.CENTER); frame.getContentPane().add(p, BorderLayout.CENTER); //4. Size the frame. frame.pack(); //5. Show it. frame.setVisible(true); }
From source file:ExposedFloat.java
public void init() { Panel buttonPanel = new PanelWithInsets(0, 0, 0, 0); buttonPanel.setLayout(new GridLayout(6, 2, 5, 5)); buttonPanel.add(maximumButton);//from ww w . j av a 2 s .co m buttonPanel.add(minimumButton); buttonPanel.add(positiveInfinityButton); buttonPanel.add(negativeInfinityButton); buttonPanel.add(piButton); buttonPanel.add(notANumberButton); buttonPanel.add(new Button(multByZeroButtonString)); buttonPanel.add(new Button(changeSignButtonString)); buttonPanel.add(new Button(doubleButtonString)); buttonPanel.add(new Button(halveButtonString)); buttonPanel.add(new RepeaterButton(incrementButtonString)); buttonPanel.add(new RepeaterButton(decrementButtonString)); binaryField = new Label("00000000000000000000000000000000"); signField = new Label("0"); exponentField = new Label("00000000"); mantissaField = new Label("000000000000000000000000"); hexField = new Label("00000000"); base2Field = new Label("0"); base10Field = new Label("0"); Font fieldFont = new Font("TimesRoman", Font.PLAIN, 12); binaryField.setFont(fieldFont); signField.setFont(fieldFont); exponentField.setFont(fieldFont); mantissaField.setFont(fieldFont); hexField.setFont(fieldFont); base2Field.setFont(fieldFont); base10Field.setFont(fieldFont); Panel numberPanel = new Panel(); numberPanel.setBackground(Color.white); numberPanel.setLayout(new GridLayout(7, 1)); numberPanel.add(signField); numberPanel.add(exponentField); numberPanel.add(mantissaField); Panel binaryPanel = new Panel(); binaryPanel.setLayout(new BorderLayout()); binaryPanel.add("Center", binaryField); numberPanel.add(binaryPanel); Panel hexPanel = new Panel(); hexPanel.setLayout(new BorderLayout()); hexPanel.add("Center", hexField); numberPanel.add(hexPanel); numberPanel.add(base2Field); numberPanel.add(base10Field); Panel labelPanel = new Panel(); labelPanel.setBackground(Color.white); labelPanel.setLayout(new GridLayout(7, 1)); Font labelFont = new Font("Helvetica", Font.ITALIC, 11); Label label = new Label(signString, Label.CENTER); label.setFont(labelFont); labelPanel.add(label); label = new Label(exponentString, Label.CENTER); label.setFont(labelFont); labelPanel.add(label); label = new Label(mantissaString, Label.CENTER); label.setFont(labelFont); labelPanel.add(label); label = new Label(binaryString, Label.CENTER); label.setFont(labelFont); labelPanel.add(label); label = new Label(hexString, Label.CENTER); label.setFont(labelFont); labelPanel.add(label); label = new Label(base2String, Label.CENTER); label.setFont(labelFont); labelPanel.add(label); label = new Label(base10String, Label.CENTER); label.setFont(labelFont); labelPanel.add(label); Panel dataPanel = new Panel(); dataPanel.setLayout(new BorderLayout()); dataPanel.add("West", labelPanel); dataPanel.add("Center", numberPanel); ColoredLabel title = new ColoredLabel(titleString, Label.CENTER, Color.cyan); title.setFont(new Font("Helvetica", Font.BOLD, 12)); setBackground(Color.green); setLayout(new BorderLayout(5, 5)); add("North", title); add("West", buttonPanel); add("Center", dataPanel); }
From source file:vincent.DynamicDataDemo.java
/** * Constructs a new demonstration application. * //from w w w . j a v a 2 s . c o m * @param title the frame title. */ public DynamicDataDemo(final String title) { super(title); this.series = new TimeSeries("Random Data"); final TimeSeriesCollection dataset = new TimeSeriesCollection(this.series); final JFreeChart chart = createChart(dataset); final ChartPanel chartPanel = new ChartPanel(chart); final JPanel content = new JPanel(new BorderLayout()); content.add(chartPanel); chartPanel.setPreferredSize(new java.awt.Dimension(500, 300)); setContentPane(content); // Zone de saisie de commande vers le port srie : TextField zoneSaisie = new TextField(10); chartPanel.add(zoneSaisie); zoneSaisie.setLocation(100, 300); zoneSaisie.validate(); zoneSaisie.addKeyListener(new KeyAdapter() { public void keyPressed(KeyEvent e) { int key = e.getKeyCode(); if (key == KeyEvent.VK_ENTER) { TextField textField = (TextField) e.getComponent(); try { BufferedWriter writer = tempSerialReader.getEcrivainPortSerie(); writer.write(textField.getText()); writer.write('\r'); writer.flush(); } catch (IOException l_ex) { LOG.error("erreur d'criture sur le port srie: ", l_ex); } } } }); temperatureCouranteLabel = new Label("XX.XC"); chartPanel.add(temperatureCouranteLabel); chartPanel.add(tempsDeChauffeEtRelicat); chartPanel.add(paramsPid); tempSerialReader = new TempSerialReader(this); }
From source file:CorrelationLambdaTest.java
@Test public void crossCorrelationGraphicTest() { CategoryTableXYDataset serie = new CategoryTableXYDataset(); serie.setNotify(false);/*from w w w . j a v a2 s . c o m*/ double step = 1.0 / discretization; double startPosition = step * framePosition; //100 ? - 100 , 50 ? - 50 , 25 ?- 25 Transform t = new Transform(new FastWaveletTransform(new Haar1())); double[] signal = testData.get1DSimpleSignal(1.5, 500, 32768, 5000); double[] data = crossCorrelationCoefficient(signal, window); // double[] data = math.convolve(testData.get1DSignal(100, 200, frameWidth, discretization), math.lpf(70, step, 128)); // double[] data = math.convolve(testData.get1DSignal(100, 200, 32768, 10000), math.lpf(70, 1./10000, 32)); // double[] data = testData.get1DSignal(100, 200, frameWidth, discretization); // double[] data = math.lpf(70, step,128); for (int i = 0; i < data.length; i++) { serie.add(startPosition, data[i], ""); startPosition += step; } JFreeChart chart = ChartFactory.createXYLineChart("", "t,c", "wave", serie); chart.removeLegend(); chart.setAntiAlias(false); XYPlot plot = chart.getXYPlot(); //plot.setRangeGridlinePaint(Color.BLACK); org.jfree.chart.axis.ValueAxis yAxis = plot.getRangeAxis(); org.jfree.chart.axis.ValueAxis xAxis = plot.getDomainAxis(); double start = framePosition * 1.0 / discretization; double max = start + frameWidth * 1.0 / discretization; xAxis.setRange(start, max); ChartPanel chartPanel = new ChartPanel(chart); JPanel p = new JPanel(new BorderLayout()); p.removeAll(); p.add(chartPanel); p.validate(); //1. Create the frame. JFrame frame = new JFrame("FrameDemo"); //2. Optional: What happens when the frame closes? frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); //3. Create components and put them in the frame. //...create emptyLabel... frame.getContentPane().add(new Label("olol"), BorderLayout.CENTER); frame.getContentPane().add(p, BorderLayout.CENTER); //4. Size the frame. frame.pack(); //5. Show it. frame.setVisible(true); }
From source file:MultipartViewer.java
protected Component getComponent(BodyPart bp) { try {//from www . java2 s .c o m DataHandler dh = bp.getDataHandler(); CommandInfo ci = dh.getCommand("view"); if (ci == null) { throw new MessagingException("view command failed on: " + bp.getContentType()); } Object bean = dh.getBean(ci); if (bean instanceof Component) { return (Component) bean; } else { if (bean == null) throw new MessagingException( "bean is null, class " + ci.getCommandClass() + " , command " + ci.getCommandName()); else throw new MessagingException("bean is not a awt.Component" + bean.getClass().toString()); } } catch (MessagingException me) { return new Label(me.toString()); } }
From source file:MultipartViewer.java
protected void setupErrorDisplay(Object content) { String error;//w w w .java 2s. c om if (content == null) error = "Content is null"; else error = "Object not of type Multipart, content class = " + content.getClass().toString(); System.out.println(error); Label lab = new Label(error); add(lab); }
From source file:MouseNavigateTest.java
protected void addCanvas3D(Canvas3D c3d) { setLayout(new BorderLayout()); add(c3d, BorderLayout.CENTER); Panel controlPanel = new Panel(); // add the UI to the frame m_RotationLabel = new Label("Rotation: "); m_RotationFieldX = new TextField("0.00"); m_RotationFieldY = new TextField("0.00"); m_RotationFieldZ = new TextField("0.00"); controlPanel.add(m_RotationLabel);// w w w .j av a 2 s .c o m controlPanel.add(m_RotationFieldX); controlPanel.add(m_RotationFieldY); controlPanel.add(m_RotationFieldZ); m_TranslationLabel = new Label("Translation: "); m_TranslationFieldX = new TextField("0.00"); m_TranslationFieldY = new TextField("0.00"); m_TranslationFieldZ = new TextField("0.00"); controlPanel.add(m_TranslationLabel); controlPanel.add(m_TranslationFieldX); controlPanel.add(m_TranslationFieldY); controlPanel.add(m_TranslationFieldZ); m_ScaleLabel = new Label("Scale: "); m_ScaleFieldX = new TextField("0.00"); m_ScaleFieldY = new TextField("0.00"); m_ScaleFieldZ = new TextField("0.00"); controlPanel.add(m_ScaleLabel); controlPanel.add(m_ScaleFieldX); controlPanel.add(m_ScaleFieldY); controlPanel.add(m_ScaleFieldZ); add(controlPanel, BorderLayout.SOUTH); doLayout(); }
From source file:NormSample.java
public void init() { // preparing values for the normalization forms ComboBox formValues.put("NFC", Normalizer.Form.NFC); formValues.put("NFD", Normalizer.Form.NFD); formValues.put("NFKC", Normalizer.Form.NFKC); formValues.put("NFKD", Normalizer.Form.NFKD); formComboBox = new JComboBox(); for (Iterator it = formValues.keySet().iterator(); it.hasNext();) { formComboBox.addItem((String) it.next()); }//from ww w. j av a2 s . c o m // preparing samples for normalization // text with the acute accent symbol templateValues.put("acute accent", "touch" + "\u00e9"); // text with ligature templateValues.put("ligature", "a" + "\ufb03" + "ance"); // text with the cedilla templateValues.put("cedilla", "fa" + "\u00e7" + "ade"); // text with half-width katakana templateValues.put("half-width katakana", "\uff81\uff6e\uff7a\uff9a\uff70\uff84"); normalizationTemplate = new JComboBox(); for (Iterator it = templateValues.keySet().iterator(); it.hasNext();) { normalizationTemplate.addItem((String) it.next()); } // defining a component to output normalization results paintingComponent = new JComponent() { static final long serialVersionUID = -3725620407788489160L; public Dimension getSize() { return new Dimension(550, 200); } public Dimension getPreferredSize() { return new Dimension(550, 200); } public Dimension getMinimumSize() { return new Dimension(550, 200); } public void paint(Graphics g) { Graphics2D g2 = (Graphics2D) g; g2.setFont(new Font("Serif", Font.PLAIN, 20)); g2.setColor(Color.BLACK); g2.drawString("Original string:", 100, 80); g2.drawString("Normalized string:", 100, 120); g2.setFont(new Font("Serif", Font.BOLD, 24)); // output of the original sample selected from the ComboBox String original_string = templateValues.get(normalizationTemplate.getSelectedItem()); g2.drawString(original_string, 320, 80); // normalization and output of the normalized string String normalized_string; java.text.Normalizer.Form currentForm = formValues.get(formComboBox.getSelectedItem()); normalized_string = Normalizer.normalize(original_string, currentForm); g2.drawString(normalized_string, 320, 120); } }; setLayout(new BoxLayout(this, BoxLayout.Y_AXIS)); add(paintingComponent); JPanel controls = new JPanel(); controls.setLayout(new BoxLayout(controls, BoxLayout.X_AXIS)); controls.add(new Label("Normalization Form: ")); controls.add(formComboBox); controls.add(new Label("Normalization Template:")); controls.add(normalizationTemplate); add(controls); formComboBox.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { paintingComponent.repaint(); } }); normalizationTemplate.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { paintingComponent.repaint(); } }); }
From source file:PlayerOfMedia.java
/*************************************************************************** * Construct a PlayerOfMedia. The Frame will have the title supplied by the * user. All initial actions on the PlayerOfMedia object are initiated * through its menu (or shotcut key).//from ww w . j a va 2s . c om **************************************************************************/ PlayerOfMedia(String name) { super(name); /////////////////////////////////////////////////////////// // Setup the menu system: a "File" menu with Open and Quit. /////////////////////////////////////////////////////////// bar = new MenuBar(); fileMenu = new Menu("File"); MenuItem openMI = new MenuItem("Open...", new MenuShortcut(KeyEvent.VK_O)); openMI.setActionCommand("OPEN"); openMI.addActionListener(this); fileMenu.add(openMI); MenuItem quitMI = new MenuItem("Quit", new MenuShortcut(KeyEvent.VK_Q)); quitMI.addActionListener(this); quitMI.setActionCommand("QUIT"); fileMenu.add(quitMI); bar.add(fileMenu); setMenuBar(bar); /////////////////////////////////////////////////////// // Layout the frame, its position on screen, and ensure // window closes are dealt with properly, including // relinquishing the resources of any Player. /////////////////////////////////////////////////////// setLayout(new BorderLayout()); setLocation(100, 100); addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { if (player != null) { player.stop(); player.close(); } System.exit(0); } }); ///////////////////////////////////////////////////// // Build the Dialog box by which the user can select // the media to play. ///////////////////////////////////////////////////// selectionDialog = new Dialog(this, "Media Selection"); Panel pan = new Panel(); pan.setLayout(new GridBagLayout()); GridBagConstraints gbc = new GridBagConstraints(); mediaName = new TextField(40); gbc.gridx = 0; gbc.gridy = 0; gbc.gridwidth = 2; pan.add(mediaName, gbc); choose = new Button("Choose File..."); gbc.ipadx = 10; gbc.ipady = 10; gbc.gridx = 2; gbc.gridwidth = 1; pan.add(choose, gbc); choose.addActionListener(this); open = new Button("Open"); gbc.gridy = 1; gbc.gridx = 1; pan.add(open, gbc); open.addActionListener(this); cancel = new Button("Cancel"); gbc.gridx = 2; pan.add(cancel, gbc); cancel.addActionListener(this); selectionDialog.add(pan); selectionDialog.pack(); selectionDialog.setLocation(200, 200); //////////////////////////////////////////////////// // Build the error Dialog box by which the user can // be informed of any errors or problems. //////////////////////////////////////////////////// errorDialog = new Dialog(this, "Error", true); errorLabel = new Label(""); errorDialog.add(errorLabel, "North"); ok = new Button("OK"); ok.addActionListener(this); errorDialog.add(ok, "South"); errorDialog.pack(); errorDialog.setLocation(150, 300); Manager.setHint(Manager.PLUGIN_PLAYER, new Boolean(true)); }
From source file:com.att.aro.ui.view.menu.datacollector.DeviceDialogOptions.java
private void setUpLabels() { String collectorTitle = ResourceBundleHelper.getMessageString("dlog.collector.option.collector.title"); String attenuatorTitle = ResourceBundleHelper.getMessageString("dlog.collector.option.attenuator.title"); String secureTitle = ResourceBundleHelper.getMessageString("dlog.collector.option.secure.title"); String videoTitle = ResourceBundleHelper.getMessageString("dlog.collector.option.video.title"); String videoOrientTitle = ResourceBundleHelper.getMessageString("dlog.collector.option.video.orient.title"); labelCollectorTitle = new Label(collectorTitle); labelAttenuatorTitle = new Label(attenuatorTitle); labelVideoTitle = new Label(videoTitle); labelVideoOrientTitle = new Label(videoOrientTitle); }