List of usage examples for javax.swing JLabel setBackground
@BeanProperty(preferred = true, visualUpdate = true, description = "The background color of the component.") public void setBackground(Color bg)
From source file:com.diversityarrays.kdxplore.KDXploreFrame.java
private Component makeComponentForTab(KdxApp kdxApp, Component uiComponent) { Component appComponent = uiComponent; DevelopmentState devState = kdxApp.getDevelopmentState(); if (devState.getShouldShowHeading()) { JLabel heading = new JLabel(devState.getHeadingText(), JLabel.CENTER); heading.setOpaque(true);// w w w . j a va 2 s.com heading.setForeground(devState.getHeadingFontColor()); heading.setBackground(Color.LIGHT_GRAY); heading.setFont(heading.getFont().deriveFont(Font.BOLD)); JPanel p = new JPanel(new BorderLayout()); p.add(heading, BorderLayout.NORTH); //Color.DARK_GRAY, Font.BOLD, Color.LIGHT_GRAY, Color.GRAY // p.add(GuiUtil.createLabelSeparator(devState.getHeadingText(), fontColor, Font.BOLD, Color.LIGHT_GRAY, Color.GRAY), // BorderLayout.NORTH); p.add(uiComponent, BorderLayout.CENTER); appComponent = p; } return appComponent; }
From source file:org.biojava.bio.view.MotifAnalyzer.java
/** * //from w w w .j av a 2 s . c o m * @param f1 sequence file * @param motifs list of motifs to display */ public void showMotifs(SequenceIterator seqItr, List<Motif> motifs) { seqViewerTab.removeAll(); seqViewerTab.setLayout(new BorderLayout()); try { Vector<Sequence> seqs = new Vector<Sequence>(); Set<MotifFinder> finders = new HashSet<MotifFinder>(); while (seqItr.hasNext()) seqs.add(seqItr.nextSequence()); // labels panel JPanel labelPanel = new JPanel(); seqViewerTab.add(labelPanel, BorderLayout.NORTH); // Sequence panels array JPanel seqViewer = new JPanel(new GridLayout(seqs.size(), 1)); seqViewerTab.add(seqViewer, BorderLayout.CENTER); SequencePanel[] seqPanel = new SequencePanel[seqs.size()]; GridLayout seqPanelLayout = new GridLayout(2, 1); seqPanelLayout.setColumns(1); seqPanelLayout.setHgap(5); seqPanelLayout.setVgap(5); seqPanelLayout.setRows(2); int i = 0; for (Iterator<Sequence> itr = seqs.iterator(); itr.hasNext(); i++) { Sequence sourceSeq = itr.next(); String name = sourceSeq.getName().substring(sourceSeq.getName().indexOf("_") + 1); seqPanel[i] = new SequencePanel(); seqPanel[i].setLayout(seqPanelLayout); int num = 0; String[] f = new String[motifs.size()]; for (Iterator<Motif> m = motifs.iterator(); m.hasNext();) { Motif motif = m.next(); if (motif.getSites().get(name) == null) continue; for (Iterator<Site> itr2 = motif.getSites().get(name).iterator(); itr2.hasNext();) { Site seq = itr2.next(); finders.add(motif.getFinder()); seq.location = new RangeLocation(sourceSeq.length() + seq.location.getMin(), sourceSeq.length() + seq.location.getMax()); seq.type = motif.getFinder().name() + "_" + num; sourceSeq.createFeature(seq); } f[num] = motif.getFinder().name() + "_" + num; num++; } seqPanel[i].setSequence(sourceSeq); seqPanel[i].setRange(new RangeLocation(1, sourceSeq.length())); // Magic number from EmblViewer seqPanel[i].setScale(Math.exp(-INITIAL_SCALE / 7.0) * 20.0); seqPanel[i].setDirection(SequencePanel.HORIZONTAL); OptimizableFilter[] optFilter = new OptimizableFilter[num];//MotifFinder.values().length]; FeatureBlockSequenceRenderer[] renderer = new FeatureBlockSequenceRenderer[num];//MotifFinder.values().length]; for (int k = 0; k < num; k++)//MotifFinder.values().length; k++) { optFilter[k] = new FeatureFilter.ByType(f[k]);//MotifFinder.values()[k].name()); renderer[k] = new FeatureBlockSequenceRenderer(new RectangularBeadRenderer(10.0f, 5.0f, Color.black, MotifFinder.valueOf(f[k].substring(0, f[k].indexOf('_'))).color, new BasicStroke())); } MultiLineRenderer multi = new MultiLineRenderer(); for (int k = 0; k < renderer.length; k++) multi.addRenderer(new FilteringRenderer(renderer[k], optFilter[k], false)); multi.addRenderer(new SymbolSequenceRenderer()); multi.addRenderer(new RulerRenderer()); seqPanel[i].setRenderer(multi); seqPanel[i].setEnabled(false); JScrollPane seqScroll = new JScrollPane(seqPanel[i]); JPanel temp = new JPanel(new BorderLayout()); temp.add(getControlBox(seqPanel[i], sourceSeq.getName()), BorderLayout.NORTH); temp.add(seqScroll, BorderLayout.CENTER); seqViewer.add(temp); } for (Iterator<MotifFinder> itr = finders.iterator(); itr.hasNext();) { MotifFinder finder = itr.next(); // Add label of this MotifFinder labelPanel.add(new JLabel(finder.name())); JLabel l = new JLabel(" "); l.setOpaque(true); l.setBackground(finder.color); l.setBorder(BorderFactory.createLineBorder(Color.black)); labelPanel.add(l); } mainFrame.setVisible(true); } catch (Exception e) { e.printStackTrace(); } }
From source file:de.tor.tribes.ui.renderer.ColoredCoutdownCellRenderer.java
@Override public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { Component c = super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column); try {/* w w w . j a v a 2s. co m*/ JLabel renderComponent = ((JLabel) c); Long d = (Long) value; // renderComponent.setText(DurationFormatUtils.formatDuration(d, "HHH:mm:ss.SSS", true)); long diff = d; long five_minutes = 5 * MINUTE; long ten_minutes = 10 * MINUTE; Color color = null; if (row % 2 == 0) { color = Constants.DS_ROW_A; } else { color = Constants.DS_ROW_B; } if (diff <= 0) { //value is expired, stroke result //renderComponent.setText(specialFormat.format(d)); //renderComponent.setForeground(Color.RED); } else if (diff <= ten_minutes && diff > five_minutes) { float ratio = (float) (diff - five_minutes) / (float) five_minutes; Color c1 = Color.YELLOW; Color c2 = Color.GREEN; int red = (int) (c2.getRed() * ratio + c1.getRed() * (1 - ratio)); int green = (int) (c2.getGreen() * ratio + c1.getGreen() * (1 - ratio)); int blue = (int) (c2.getBlue() * ratio + c1.getBlue() * (1 - ratio)); color = new Color(red, green, blue); } else if (diff <= five_minutes) { float ratio = (float) diff / (float) five_minutes; Color c1 = Color.RED; Color c2 = Color.YELLOW; int red = (int) (c2.getRed() * ratio + c1.getRed() * (1 - ratio)); int green = (int) (c2.getGreen() * ratio + c1.getGreen() * (1 - ratio)); int blue = (int) (c2.getBlue() * ratio + c1.getBlue() * (1 - ratio)); color = new Color(red, green, blue); } renderComponent.setText(DurationFormatUtils.formatDuration(d, "HHH:mm:ss.SSS", true)); if (isSelected) { color = c.getBackground(); } renderComponent.setOpaque(true); renderComponent.setBackground(color); return renderComponent; } catch (Exception e) { return c; } }
From source file:Clavis.Windows.WShedule.java
/** * This method is called from within the constructor to initialize the form. * WARNING: Do NOT modify this code. The content of this method is always * regenerated by the Form Editor.//w ww .j a v a 2 s . com */ @SuppressWarnings("unchecked") // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents private void initComponents() { jPanelInicial = new javax.swing.JPanel(); jScrollPane1 = new javax.swing.JScrollPane(); jTable1 = new org.jdesktop.swingx.JXTable(); ; jButtonSair = new javax.swing.JButton(); jXDatePickerInicio = new org.jdesktop.swingx.JXDatePicker(); jXDatePickerFim = new org.jdesktop.swingx.JXDatePicker(); jLabel1 = new javax.swing.JLabel(); jLabel2 = new javax.swing.JLabel(); jButtonImprimir = new javax.swing.JButton(); jComboBoxEstado = new javax.swing.JComboBox<>(); jLabel3 = new javax.swing.JLabel(); jButtonExportar = new javax.swing.JButton(); setMinimumSize(new java.awt.Dimension(900, 600)); setSize(new java.awt.Dimension(900, 600)); jPanelInicial.setBorder(javax.swing.BorderFactory.createCompoundBorder( javax.swing.BorderFactory.createLineBorder(painelcor, 4), javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)))); jPanelInicial.setMinimumSize(new java.awt.Dimension(900, 500)); jPanelInicial.setPreferredSize(new java.awt.Dimension(900, 500)); org.jdesktop.swingx.border.DropShadowBorder dropShadowBorder1 = new org.jdesktop.swingx.border.DropShadowBorder(); dropShadowBorder1.setCornerSize(6); dropShadowBorder1.setShadowSize(3); dropShadowBorder1.setShowLeftShadow(true); jScrollPane1.setBorder(javax.swing.BorderFactory.createCompoundBorder(dropShadowBorder1, javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)))); jTable1.setBorder(null); if (mat.getTypeOfMaterial().getMaterialTypeID() == 1) { jTable1.setModel(new javax.swing.table.DefaultTableModel(new Object[][] {}, new String[] { lingua.translate("Utilizador"), lingua.translate("Horrio"), lingua.translate("Data"), lingua.translate("Atividade"), lingua.translate("Disciplina") })); jTable1.getColumnModel().getColumn(0).setPreferredWidth(250); jTable1.getColumnModel().getColumn(1).setMinWidth(90); jTable1.getColumnModel().getColumn(2).setMinWidth(90); jTable1.getColumnModel().getColumn(3).setMinWidth(150); jTable1.getColumnModel().getColumn(4).setMinWidth(150); } else { jTable1.setModel(new javax.swing.table.DefaultTableModel(new Object[][] {}, new String[] { lingua.translate("Utilizador"), lingua.translate("Data inicial"), lingua.translate("Data final"), lingua.translate("Atividade") })); jTable1.getColumnModel().getColumn(0).setPreferredWidth(250); jTable1.getColumnModel().getColumn(1).setMinWidth(90); jTable1.getColumnModel().getColumn(2).setMinWidth(90); jTable1.getColumnModel().getColumn(3).setMinWidth(150); } jScrollPane1.setViewportView(jTable1); Border border = BorderFactory.createEmptyBorder(5, 5, 0, 0); UIManager.put("Table.focusCellHighlightBorder", border); jTable1.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); DefaultTableCellRenderer renderer = new DefaultTableCellRenderer(); renderer.setHorizontalAlignment(javax.swing.JLabel.CENTER); renderer.setFocusable(false); javax.swing.JLabel lo = new javax.swing.JLabel(); lo.setBackground(new Color(100, 100, 100)); lo.setOpaque(true); jScrollPane1.setCorner(javax.swing.JScrollPane.UPPER_TRAILING_CORNER, lo); jTable1.setRowHeight(30); jTable1.setEditable(false); jTable1.setSelectionBackground(Color.DARK_GRAY); jTable1.getColumnModel().getColumn(1).setCellRenderer(renderer); jTable1.getColumnModel().getColumn(2).setCellRenderer(renderer); jTable1.getColumnModel().getColumn(3).setCellRenderer(renderer); if (mat.getTypeOfMaterial().getMaterialTypeID() == 1) { jTable1.getColumnModel().getColumn(4).setCellRenderer(renderer); } DefaultTableCellRenderer headerRenderer = new DefaultTableCellRenderer() { private static final long serialVersionUID = 2L; @Override public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column); setFont(new Font("Cantarell", Font.PLAIN, 14)); this.setBorder(BorderFactory.createMatteBorder(0, 1, 1, 0, new Color(1, 1, 1))); return this; } }; DefaultTableCellRenderer headerRenderer2 = new DefaultTableCellRenderer() { private static final long serialVersionUID = 3L; @Override public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column); setFont(new Font("Cantarell", Font.PLAIN, 14)); this.setBorder(BorderFactory.createCompoundBorder( BorderFactory.createMatteBorder(0, 0, 1, 0, new Color(1, 1, 1)), BorderFactory.createEmptyBorder(0, 20, 0, 0))); this.setBackground(new Color(100, 100, 100)); setForeground(Color.WHITE); setPreferredSize(new Dimension(100, 40)); return this; } }; headerRenderer.setBackground(new Color(100, 100, 100)); headerRenderer.setForeground(Color.WHITE); headerRenderer.setPreferredSize(new Dimension(100, 40)); headerRenderer.setHorizontalAlignment(javax.swing.JLabel.CENTER); for (int i = 0; i < jTable1.getColumnCount(); i++) { if (i == 0) { headerRenderer2.setHorizontalAlignment(javax.swing.JLabel.LEFT); jTable1.getColumnModel().getColumn(i).setHeaderRenderer(headerRenderer2); } else { jTable1.getColumnModel().getColumn(i).setHeaderRenderer(headerRenderer); } } jButtonSair.setBackground(new java.awt.Color(1, 1, 1)); jButtonSair.setToolTipText(""); jButtonSair.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR)); jButtonSair.setFocusPainted(false); jButtonSair.setMaximumSize(new java.awt.Dimension(90, 40)); jButtonSair.setMinimumSize(new java.awt.Dimension(90, 40)); jButtonSair.setPreferredSize(new java.awt.Dimension(90, 40)); jButtonSair.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButtonSairActionPerformed(evt); } }); jXDatePickerInicio.setBackground(new java.awt.Color(254, 254, 254)); org.jdesktop.swingx.border.DropShadowBorder dropShadowBorder2 = new org.jdesktop.swingx.border.DropShadowBorder(); dropShadowBorder2.setCornerSize(6); dropShadowBorder2.setShadowSize(3); dropShadowBorder2.setShowLeftShadow(true); jXDatePickerInicio.setBorder(javax.swing.BorderFactory.createCompoundBorder(dropShadowBorder2, javax.swing.BorderFactory.createMatteBorder(0, 1, 1, 1, new java.awt.Color(0, 0, 0)))); jXDatePickerInicio.setFont(new java.awt.Font("Cantarell", 0, 12)); // NOI18N jXDatePickerInicio.setMaximumSize(new java.awt.Dimension(1155551, 26)); jXDatePickerInicio.setMinimumSize(new java.awt.Dimension(66, 26)); jXDatePickerInicio.setPreferredSize(new java.awt.Dimension(131, 26)); jXDatePickerInicio.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jXDatePickerInicioActionPerformed(evt); } }); jXDatePickerFim.setBackground(new java.awt.Color(254, 254, 254)); org.jdesktop.swingx.border.DropShadowBorder dropShadowBorder3 = new org.jdesktop.swingx.border.DropShadowBorder(); dropShadowBorder3.setCornerSize(6); dropShadowBorder3.setShadowSize(3); dropShadowBorder3.setShowLeftShadow(true); jXDatePickerFim.setBorder(javax.swing.BorderFactory.createCompoundBorder(dropShadowBorder3, javax.swing.BorderFactory.createMatteBorder(0, 1, 1, 1, new java.awt.Color(0, 0, 0)))); jXDatePickerFim.setFont(new java.awt.Font("Cantarell", 0, 12)); // NOI18N jXDatePickerFim.setMaximumSize(new java.awt.Dimension(1155551, 26)); jXDatePickerFim.setMinimumSize(new java.awt.Dimension(66, 26)); jXDatePickerFim.setPreferredSize(new java.awt.Dimension(121, 26)); jLabel1.setBackground(new java.awt.Color(100, 100, 100)); jLabel1.setFont(new java.awt.Font("Cantarell", 0, 12)); // NOI18N jLabel1.setForeground(new java.awt.Color(254, 254, 254)); jLabel1.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); jLabel1.setText("Incio"); jLabel1.setVerticalAlignment(javax.swing.SwingConstants.TOP); jLabel1.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0))); jLabel1.setHorizontalTextPosition(javax.swing.SwingConstants.RIGHT); jLabel1.setMaximumSize(new java.awt.Dimension(3343446, 96)); jLabel1.setMinimumSize(new java.awt.Dimension(36, 26)); jLabel1.setOpaque(true); jLabel1.setPreferredSize(new java.awt.Dimension(100, 20)); jLabel2.setBackground(new java.awt.Color(100, 100, 100)); jLabel2.setFont(new java.awt.Font("Cantarell", 0, 12)); // NOI18N jLabel2.setForeground(new java.awt.Color(254, 254, 254)); jLabel2.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); jLabel2.setText("Fim"); jLabel2.setVerticalAlignment(javax.swing.SwingConstants.TOP); jLabel2.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0))); jLabel2.setMaximumSize(new java.awt.Dimension(355557, 96)); jLabel2.setMinimumSize(new java.awt.Dimension(37, 26)); jLabel2.setOpaque(true); jLabel2.setPreferredSize(new java.awt.Dimension(100, 20)); jButtonImprimir.setBackground(new java.awt.Color(51, 102, 153)); jButtonImprimir.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR)); jButtonImprimir.setFocusPainted(false); jButtonImprimir.setMaximumSize(new java.awt.Dimension(5345, 40)); jButtonImprimir.setPreferredSize(new java.awt.Dimension(90, 40)); jButtonImprimir.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButtonImprimirActionPerformed(evt); } }); jComboBoxEstado.setBackground(new java.awt.Color(213, 213, 213)); jComboBoxEstado.setBorder(null); jComboBoxEstado.setFocusable(false); jComboBoxEstado.setMinimumSize(new java.awt.Dimension(35, 22)); jComboBoxEstado.setPreferredSize(new java.awt.Dimension(125, 28)); jComboBoxEstado.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jComboBoxEstadoActionPerformed(evt); } }); jLabel3.setBackground(new java.awt.Color(100, 100, 100)); jLabel3.setFont(new java.awt.Font("Cantarell", 0, 12)); // NOI18N jLabel3.setForeground(new java.awt.Color(254, 254, 254)); jLabel3.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); jLabel3.setText("Estado"); jLabel3.setVerticalAlignment(javax.swing.SwingConstants.TOP); jLabel3.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0))); jLabel3.setMaximumSize(new java.awt.Dimension(355557, 96)); jLabel3.setMinimumSize(new java.awt.Dimension(37, 26)); jLabel3.setOpaque(true); jLabel3.setPreferredSize(new java.awt.Dimension(100, 20)); jButtonExportar.setBackground(new java.awt.Color(51, 102, 153)); jButtonExportar.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR)); jButtonExportar.setFocusPainted(false); jButtonExportar.setMaximumSize(new java.awt.Dimension(5345, 40)); jButtonExportar.setPreferredSize(new java.awt.Dimension(90, 40)); jButtonExportar.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButtonExportarActionPerformed(evt); } }); javax.swing.GroupLayout jPanelInicialLayout = new javax.swing.GroupLayout(jPanelInicial); jPanelInicial.setLayout(jPanelInicialLayout); jPanelInicialLayout.setHorizontalGroup(jPanelInicialLayout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanelInicialLayout.createSequentialGroup().addGap(42, 42, 42) .addGroup(jPanelInicialLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanelInicialLayout.createSequentialGroup().addComponent(jScrollPane1) .addGap(42, 42, 42)) .addGroup(jPanelInicialLayout.createSequentialGroup().addGap(29, 29, 29) .addComponent(jButtonSair, javax.swing.GroupLayout.PREFERRED_SIZE, 90, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(jButtonExportar, javax.swing.GroupLayout.PREFERRED_SIZE, 90, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jButtonImprimir, javax.swing.GroupLayout.PREFERRED_SIZE, 90, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(71, 71, 71)))) .addGroup(jPanelInicialLayout.createSequentialGroup().addGap(71, 71, 71) .addGroup(jPanelInicialLayout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) .addComponent(jLabel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(jXDatePickerInicio, javax.swing.GroupLayout.DEFAULT_SIZE, 152, Short.MAX_VALUE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(jPanelInicialLayout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) .addComponent(jLabel2, javax.swing.GroupLayout.DEFAULT_SIZE, 152, Short.MAX_VALUE) .addComponent(jXDatePickerFim, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 201, Short.MAX_VALUE) .addGroup(jPanelInicialLayout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) .addComponent(jLabel3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(jComboBoxEstado, 0, 241, Short.MAX_VALUE)) .addGap(71, 71, 71))); jPanelInicialLayout .setVerticalGroup(jPanelInicialLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanelInicialLayout.createSequentialGroup().addGap(16, 16, 16) .addGroup(jPanelInicialLayout .createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGap(0, 0, 0) .addGroup(jPanelInicialLayout .createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jXDatePickerInicio, javax.swing.GroupLayout.PREFERRED_SIZE, 31, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jXDatePickerFim, javax.swing.GroupLayout.PREFERRED_SIZE, 31, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jComboBoxEstado, javax.swing.GroupLayout.PREFERRED_SIZE, 28, javax.swing.GroupLayout.PREFERRED_SIZE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 465, Short.MAX_VALUE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(jPanelInicialLayout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jButtonImprimir, javax.swing.GroupLayout.PREFERRED_SIZE, 40, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jButtonSair, javax.swing.GroupLayout.PREFERRED_SIZE, 40, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jButtonExportar, javax.swing.GroupLayout.PREFERRED_SIZE, 40, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGap(16, 16, 16))); try { if (Clavis.KeyQuest.class.getResource("Images/exit26x24.png") != null) { BufferedImage im = ImageIO.read(Clavis.KeyQuest.class.getResourceAsStream("Images/exit26x24.png")); ImageIcon imic = new ImageIcon(im); if (imic != null) { jButtonSair.setIcon(imic); } } } catch (IOException eo) { } jButtonSair.setToolTipText(lingua.translate("Voltar")); javax.swing.JPanel pan2 = new javax.swing.JPanel(null); String compoe = lingua.translate("Hoje dia") + ": " + new TimeDate.Date().toString(); javax.swing.JLabel fil2 = new javax.swing.JLabel(compoe); fil2.setBounds(0, 0, 300, 26); fil2.setHorizontalAlignment(SwingConstants.CENTER); pan2.setPreferredSize(new Dimension(300, 30)); pan2.setBounds(0, 0, 300, 30); pan2.add(fil2); jXDatePickerInicio.setLinkPanel(pan2); jXDatePickerInicio.setLocale(lingua.systemlocale); jXDatePickerInicio.getEditor().setSelectionColor(Color.DARK_GRAY); jXDatePickerInicio.getEditor().setBorder(BorderFactory.createEmptyBorder()); jXDatePickerInicio.getEditor().setHorizontalAlignment(SwingConstants.CENTER); javax.swing.JButton bbt2 = (javax.swing.JButton) jXDatePickerInicio.getComponent(1); bbt2.setBackground(Color.WHITE); jXDatePickerInicio.addActionListener(actionJXDatePicker()); jXDatePickerInicio.setFormats("dd/MM/yyyy"); javax.swing.JPanel pan = new javax.swing.JPanel(null); String compoe0 = lingua.translate("Hoje dia") + ": " + new TimeDate.Date().toString(); javax.swing.JLabel fil = new javax.swing.JLabel(compoe); fil.setBounds(0, 0, 300, 26); fil.setHorizontalAlignment(SwingConstants.CENTER); pan.setPreferredSize(new Dimension(300, 30)); pan.setBounds(0, 0, 300, 30); pan.add(fil); jXDatePickerFim.setLinkPanel(pan); Component[] t = jXDatePickerFim.getLinkPanel().getComponents(); jXDatePickerFim.setLocale(lingua.systemlocale); jXDatePickerFim.getEditor().setSelectionColor(Color.DARK_GRAY); jXDatePickerFim.getEditor().setBorder(BorderFactory.createEmptyBorder()); jXDatePickerFim.getEditor().setHorizontalAlignment(SwingConstants.CENTER); javax.swing.JButton bbt = (javax.swing.JButton) jXDatePickerFim.getComponent(1); bbt.setBackground(Color.WHITE); jXDatePickerFim.addActionListener(actionJXDatePicker()); jXDatePickerFim.setFormats("dd/MM/yyyy"); jLabel1.setText(lingua.translate("Incio")); jLabel2.setText(lingua.translate("Fim")); try { if (Clavis.KeyQuest.class.getResource("Images/print.png") != null) { BufferedImage im = ImageIO.read(Clavis.KeyQuest.class.getResourceAsStream("Images/print.png")); ImageIcon imic = new ImageIcon(im); if (imic != null) { jButtonImprimir.setIcon(imic); } } } catch (IOException eo) { } jButtonImprimir.setToolTipText(lingua.translate("Imprimir")); jComboBoxEstado.setModel(new javax.swing.DefaultComboBoxModel<>( new String[] { lingua.translate("todos"), lingua.translate("terminado"), lingua.translate("no realizado"), lingua.translate("por realizar") })); Clavis.KeyQuest.addVisualComboBox(jComboBoxEstado); ((javax.swing.JLabel) jComboBoxEstado.getRenderer()).setHorizontalAlignment(javax.swing.JLabel.CENTER); jLabel3.setText(lingua.translate("Estado")); try { if (Clavis.KeyQuest.class.getResource("Images/exportar.png") != null) { BufferedImage im = ImageIO.read(Clavis.KeyQuest.class.getResourceAsStream("Images/exportar.png")); ImageIcon imic = new ImageIcon(im); if (imic != null) { jButtonExportar.setIcon(imic); } } } catch (IOException eo) { } jButtonExportar.setToolTipText(lingua.translate("Exportar para excel")); javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); getContentPane().setLayout(layout); layout.setHorizontalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup().addComponent(jPanelInicial, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addGap(0, 0, 0))); layout.setVerticalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jPanelInicial, javax.swing.GroupLayout.DEFAULT_SIZE, 600, Short.MAX_VALUE)); }
From source file:com.rapidminer.gui.new_plotter.gui.ColorSchemeDialog.java
/** * @return//from w ww .ja v a 2 s. c o m */ private JPanel createSchemeComboBoxPanel() { JPanel schemeListPanel = new JPanel(new GridBagLayout()); // create categories configuration panel { GridBagConstraints itemConstraint = new GridBagConstraints(); // Add active scheme label JLabel actviceSchemeLabel = new ResourceLabel( "plotter.configuration_dialog.color_scheme_dialog.active_scheme"); { itemConstraint.fill = GridBagConstraints.HORIZONTAL; itemConstraint.anchor = GridBagConstraints.WEST; itemConstraint.gridwidth = GridBagConstraints.RELATIVE; itemConstraint.insets = new Insets(0, 5, 5, 5); itemConstraint.weightx = 1.0; actviceSchemeLabel.setBackground(Color.red); schemeListPanel.add(actviceSchemeLabel, itemConstraint); } // add button panel { JPanel buttonPanel = new JPanel(new GridBagLayout()); // rename scheme button { renameSchemeButton = new JButton(new ResourceAction(true, "plotter.configuration_dialog.color_scheme_dialog.rename_scheme_button") { private static final long serialVersionUID = 1L; @Override public void actionPerformed(ActionEvent e) { String newName = createNameDialog(currentActiveColorSchemeName); if (newName != null && !newName.equals(currentActiveColorSchemeName)) { renameColorSchemeAction(newName); } } }); itemConstraint = new GridBagConstraints(); itemConstraint.gridwidth = GridBagConstraints.RELATIVE; itemConstraint.fill = GridBagConstraints.NONE; buttonPanel.add(renameSchemeButton, itemConstraint); } // remove scheme button { removeSchemeButton = new JButton(new ResourceAction(true, "plotter.configuration_dialog.color_scheme_dialog.remove_scheme_button") { private static final long serialVersionUID = 1L; @Override public void actionPerformed(ActionEvent e) { ConfirmDialog dialog = new ConfirmDialog( SwingUtilities.getWindowAncestor((Component) e.getSource()), "plotter.configuration_dialog.confirm_color_scheme_delete", ConfirmDialog.YES_NO_OPTION, false); dialog.setLocationRelativeTo((Component) e.getSource()); dialog.setVisible(true); if (dialog.getReturnOption() == ConfirmDialog.YES_OPTION) { removeColorSchemeAction((ColorScheme) colorSchemeComboBox.getSelectedItem()); } } }); itemConstraint = new GridBagConstraints(); itemConstraint.gridwidth = GridBagConstraints.REMAINDER; itemConstraint.fill = GridBagConstraints.NONE; buttonPanel.add(removeSchemeButton, itemConstraint); } itemConstraint = new GridBagConstraints(); itemConstraint.gridwidth = GridBagConstraints.REMAINDER; itemConstraint.fill = GridBagConstraints.NONE; itemConstraint.anchor = GridBagConstraints.EAST; itemConstraint.insets = new Insets(0, 5, 5, 5); schemeListPanel.add(buttonPanel, itemConstraint); } { colorSchemeComboBox = new JComboBox(colorSchemeComboBoxModel); actviceSchemeLabel.setLabelFor(colorSchemeComboBox); colorSchemeComboBox.setRenderer(new ColorSchemeComboBoxRenderer()); colorSchemeComboBox.addPopupMenuListener(new PopupMenuListener() { @Override public void popupMenuWillBecomeVisible(PopupMenuEvent e) { return; } @Override public void popupMenuWillBecomeInvisible(PopupMenuEvent e) { Object selectedValue = colorSchemeComboBox.getSelectedItem(); if (selectedValue instanceof ColorScheme) { ColorScheme selection = (ColorScheme) selectedValue; if (selection != null) { if (!currentActiveColorSchemeName.equals(selection.getName())) { currentActiveColorSchemeName = selection.getName(); adaptModels(); } } } else { String newName = I18N.getGUILabel("plotter.new_color_scheme_name.label"); String suffix = ""; int counter = 1; while (currentColorSchemes.get(newName + suffix) != null) { suffix = "_" + counter; counter++; } newName += suffix; String userSelectedName = createNameDialog(newName); if (userSelectedName == null) { colorSchemeComboBox.setSelectedItem(getCurrentActiveColorScheme()); return; } addNewColorSchemeAction(userSelectedName); } } @Override public void popupMenuCanceled(PopupMenuEvent e) { return; } }); itemConstraint = new GridBagConstraints(); itemConstraint.fill = GridBagConstraints.BOTH; itemConstraint.weightx = 0.0; itemConstraint.weighty = 0.0; itemConstraint.gridwidth = GridBagConstraints.REMAINDER; schemeListPanel.add(colorSchemeComboBox, itemConstraint); } } return schemeListPanel; }
From source file:web.diva.server.model.SomClustering.SomClustImgGenerator.java
public void drawTable(Graphics gr, Point UL, Dataset dataset, int[] selection, Graphics navgGr, int countNavUnit) { Font f = getTableFont(squareL - 1); AnnotationManager annManager = AnnotationManager.getAnnotationManager(); String[] rowIds = dataset.getRowIds(); Set<String> annotations = dataset.getRowAnnotationNamesInUse(); if (annotations == null) { annotations = annManager.getManagedRowAnnotationNames(); }//from www .java 2s.co m String[][] inf; // row annotation matrix String[] headers; // header of the row annotation matrix if (annotations.isEmpty()) { inf = new String[dataset.getDataLength()][1]; for (int i = 0; i < inf.length; i++) { inf[i][0] = rowIds[i]; } headers = new String[] { "Row ID" }; } else { headers = annotations.toArray(new String[annotations.size()]); inf = new String[dataset.getDataLength()][annotations.size()]; for (int i = 0; i < headers.length; i++) { //ann manager need to re implemeinted? AnnotationLibrary anns = annManager.getRowAnnotations(headers[i]); for (int j = 0; j < inf.length; j++) { inf[j][i] = rowIds[j];//anns.getAnnotation(rowIds[j]);// } } } Graphics2D g2d = (Graphics2D) gr; Graphics2D g2dNav = (Graphics2D) navgGr; g2d.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON); g2dNav.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON); int X = UL.x; int Y = UL.y; // int H = squareL; int L = dataset.getDataLength(); int W = headers.length; JLabel l = new JLabel(" "); JLabel lNav = new JLabel(" "); // l.setFont(f); // l.setIconTextGap(2); javax.swing.border.Border UB = javax.swing.BorderFactory.createMatteBorder(0, 0, 0, 0, Color.WHITE); javax.swing.border.Border LB = javax.swing.BorderFactory.createMatteBorder(0, 0, 0, 0, Color.WHITE); // Color borderColor = hex2Rgb("#e3e3e3"); javax.swing.border.Border navBorder = javax.swing.BorderFactory.createMatteBorder(2, 0, 0, 0, Color.WHITE); l.setMaximumSize(new Dimension(200, squareL)); lNav.setSize(new Dimension(2, 5)); lNav.setBorder(navBorder); boolean drawTableHeader = false; //if there is not enough room for a header.. skip header. // if (UL.y < squareL) { // drawTableHeader = false; // } if (Wd == null) { Wd = new int[inf[0].length]; WdSUM = new int[inf[0].length]; if (drawTableHeader) { for (int i = 0; i < headers.length; i++) { l.setText(headers[i]); l.validate(); if (l.getPreferredSize().width > Wd[i]) { Wd[i] = l.getPreferredSize().width + 16; } } } for (String[] inf1 : inf) { for (int j = 0; j < Wd.length; j++) { if (squareL < 6) { Wd[j] = 5; continue; } l.setText(inf1[j]); l.validate(); if (l.getPreferredSize().width > Wd[j]) { Wd[j] = l.getPreferredSize().width + 16; } } } WdSUM[0] = 0; for (int i = 0; i < Wd.length; i++) { WdSUM[i] = -1; for (int j = 0; j < i; j++) { WdSUM[i] += Wd[j] + 3; } } } Rectangle BNDS = new Rectangle(); l.setBackground(Color.WHITE); l.setOpaque(true); lNav.setBackground(Color.WHITE); lNav.setOpaque(true); if (sideTree == null) { return; } f = getTableFont(squareL - 1); l.setFont(f); int[] LArr = sideTree.arrangement; int Rindex = 0; //draw the table header.. (if wanted) // if (drawTableHeader) { // // l.setBackground(Color.WHITE); // l.setForeground(Color.white); // // for (int j = 0; j < W; j++) { // X = UL.x + WdSUM[j]; // Y = UL.y; // BNDS.setBounds(X, Y, Wd[j], squareL + 1); // // if (gr.getClipBounds() != null && !gr.getClipBounds().intersects(BNDS)) { // continue; // } // gr.translate(X, Y); // l.setBounds(0, 0, Wd[j] + 1, squareL + 1); // l.setBorder(LB); // // if (squareL >= 6) { // l.setText(headers[j]); // } // l.validate(); // l.paint(gr); // gr.translate(-X, -Y); // } // } l.setForeground(Color.WHITE); boolean[] sel = selectedRows((selection == null ? null : selection), dataset); boolean coloredNav = false; int navCounter = 0; for (int i = 0; i < L; i++) { Rindex = LArr[i]; for (int j = 0; j < W; j++) { X = UL.x + WdSUM[j]; Y = UL.y + (squareL * (i + 1)); BNDS.setBounds(X, Y, Wd[j], squareL + 1); if (gr.getClipBounds() != null && !gr.getClipBounds().intersects(BNDS)) { continue; } if (sel[LArr[i]]) { for (Group group : dataset.getRowGroups()) { if (group.isActive()) { if (group.hasMember(Rindex)) { l.setBackground(group.getColor()); if (!coloredNav) { lNav.setBackground(Color.RED); lNav.setForeground(Color.RED); coloredNav = true; } break; } } } // l.setBackground(new Color(225, 225, 255)); } else { // // if (!coloredNav) { // lNav.setBackground(Color.WHITE); // lNav.setForeground(Color.WHITE); // } l.setBackground(Color.WHITE); } if (i != 0) gr.translate(X, Y); l.setBounds(0, 0, Wd[j] + 1, squareL + 1); if (i < L - 1) { l.setBorder(UB); } else { l.setBounds(0, 0, Wd[j] + 1, squareL + 1); l.setBorder(LB); } if (squareL >= 6) { l.setText(inf[Rindex][j]); } l.validate(); l.paint(gr); gr.translate(-X, -Y); } if (navCounter >= countNavUnit) { navCounter = 0; lNav.validate(); lNav.paint(navgGr); navgGr.translate(2, 0); coloredNav = false; lNav.setBackground(Color.WHITE); lNav.setForeground(Color.WHITE); } navCounter++; } // if (squareL < 6) { // return; // } // // l.setBackground(Color.WHITE); // f = getTableFont(squareL - 2); // //f = new Font("Arial",1,squareL-2); // l.setFont(f); // // // for (int j = 0; j < W; j++) { // X = UL.x + WdSUM[j]; // Y = UL.y; // // BNDS.setBounds(X, Y, Wd[j], squareL + 1); // if (gr.getClipBounds() != null && !gr.getClipBounds().intersects(BNDS)) { // continue; // } // // gr.translate(X, Y); // l.setBounds(0, 0, Wd[j], squareL + 1); //// l.setBorder(javax.swing.BorderFactory.createLineBorder(GridCol)); // l.setText(headers[j]); // l.validate(); // gr.translate(-X, -Y); // } }
From source file:self.philbrown.javaQuery.$.java
/** * Include the html string the selected views. If a view has a setText method, it is used. Otherwise, * a new TextView is created. This html can also handle image tags for both urls and local files. * Local files should be the name (for example, for R.id.ic_launcher, just use ic_launcher). * @param html the HTML String to include *//* w ww. j a va 2 s . co m*/ public $ html(String html) { for (Component view : this.views) { try { Method m = view.getClass().getMethod("setText", new Class<?>[] { String.class }); m.invoke(view, html); } catch (Throwable t) { if (view instanceof Container) { try { //no setText method. Try a TextView JLabel label = new JLabel(); int rgba = Color.HSBtoRGB(0, 0, 0); rgba |= (0 & 0xff); label.setBackground(new Color(rgba, true)); label.setBounds(label.getParent().getBounds()); ((Container) view).add(label); label.setText(html); } catch (Throwable t2) { //unable to set content Log.w("javaQuery", "unable to set HTML content"); } } else { //unable to set content Log.w("javaQuery", "unable to set textual content"); } } } return this; }
From source file:self.philbrown.javaQuery.$.java
/** * Includes the given text string inside of the selected views. If a view has a setText method, it is used * otherwise, if possible, a textview is added as a child to display the text. * @param text the text to include/*from ww w . j ava2s.c o m*/ */ public $ text(String text) { for (Component view : this.views) { try { Method m = view.getClass().getMethod("setText", new Class<?>[] { String.class }); m.invoke(view, text); } catch (Throwable t) { if (view instanceof Container) { try { //no setText method. Try a TextView JLabel label = new JLabel(); int rgba = Color.HSBtoRGB(0, 0, 0); rgba |= (0 & 0xff); label.setBackground(new Color(rgba, true)); label.setBounds(label.getParent().getBounds()); ((Container) view).add(label); label.setText(text); } catch (Throwable t2) { //unable to set content Log.w("javaQuery", "unable to set textual content"); } } else { //unable to set content Log.w("javaQuery", "unable to set textual content"); } } } return this; }
From source file:com.nikonhacker.gui.EmulatorUI.java
private void openChipOptionsDialog(final int chip) { // ------------------------ Disassembly options JPanel disassemblyOptionsPanel = new JPanel(new MigLayout("", "[left,grow][left,grow]")); // Prepare sample code area final RSyntaxTextArea listingArea = new RSyntaxTextArea(20, 90); SourceCodeFrame.prepareAreaFormat(chip, listingArea); final List<JCheckBox> outputOptionsCheckBoxes = new ArrayList<JCheckBox>(); ActionListener areaRefresherListener = new ActionListener() { public void actionPerformed(ActionEvent e) { try { Set<OutputOption> sampleOptions = EnumSet.noneOf(OutputOption.class); dumpOptionCheckboxes(outputOptionsCheckBoxes, sampleOptions); int baseAddress = framework.getPlatform(chip).getCpuState().getResetAddress(); int lastAddress = baseAddress; Memory sampleMemory = new DebuggableMemory(false); sampleMemory.map(baseAddress, 0x100, true, true, true); StringWriter writer = new StringWriter(); Disassembler disassembler; if (chip == Constants.CHIP_FR) { sampleMemory.store16(lastAddress, 0x1781); // PUSH RP lastAddress += 2;/*w w w .j a va2 s . c om*/ sampleMemory.store16(lastAddress, 0x8FFE); // PUSH (FP,AC,R12,R11,R10,R9,R8) lastAddress += 2; sampleMemory.store16(lastAddress, 0x83EF); // ANDCCR #0xEF lastAddress += 2; sampleMemory.store16(lastAddress, 0x9F80); // LDI:32 #0x68000000,R0 lastAddress += 2; sampleMemory.store16(lastAddress, 0x6800); lastAddress += 2; sampleMemory.store16(lastAddress, 0x0000); lastAddress += 2; sampleMemory.store16(lastAddress, 0x2031); // LD @(FP,0x00C),R1 lastAddress += 2; sampleMemory.store16(lastAddress, 0xB581); // LSL #24,R1 lastAddress += 2; sampleMemory.store16(lastAddress, 0x1A40); // DMOVB R13,@0x40 lastAddress += 2; sampleMemory.store16(lastAddress, 0x9310); // ORCCR #0x10 lastAddress += 2; sampleMemory.store16(lastAddress, 0x8D7F); // POP (R8,R9,R10,R11,R12,AC,FP) lastAddress += 2; sampleMemory.store16(lastAddress, 0x0781); // POP RP lastAddress += 2; disassembler = new Dfr(); disassembler.setDebugPrintWriter(new PrintWriter(new StringWriter())); // Ignore disassembler.setOutputFileName(null); disassembler.processOptions(new String[] { "-m", "0x" + Format.asHex(baseAddress, 8) + "-0x" + Format.asHex(lastAddress, 8) + "=CODE" }); } else { sampleMemory.store32(lastAddress, 0x340B0001); // li $t3, 0x0001 lastAddress += 4; sampleMemory.store32(lastAddress, 0x17600006); // bnez $k1, 0xBFC00020 lastAddress += 4; sampleMemory.store32(lastAddress, 0x00000000); // nop lastAddress += 4; sampleMemory.store32(lastAddress, 0x54400006); // bnezl $t4, 0xBFC00028 lastAddress += 4; sampleMemory.store32(lastAddress, 0x3C0C0000); // ?lui $t4, 0x0000 lastAddress += 4; int baseAddress16 = lastAddress; int lastAddress16 = baseAddress16; sampleMemory.store32(lastAddress16, 0xF70064F6); // save $ra,$s0,$s1,$s2-$s7,$fp, 0x30 lastAddress16 += 4; sampleMemory.store16(lastAddress16, 0x6500); // nop lastAddress16 += 2; sampleMemory.store32(lastAddress16, 0xF7006476); // restore $ra,$s0,$s1,$s2-$s7,$fp, 0x30 lastAddress16 += 4; sampleMemory.store16(lastAddress16, 0xE8A0); // ret lastAddress16 += 2; disassembler = new Dtx(); disassembler.setDebugPrintWriter(new PrintWriter(new StringWriter())); // Ignore disassembler.setOutputFileName(null); disassembler.processOptions(new String[] { "-m", "0x" + Format.asHex(baseAddress, 8) + "-0x" + Format.asHex(lastAddress, 8) + "=CODE:32", "-m", "0x" + Format.asHex(baseAddress16, 8) + "-0x" + Format.asHex(lastAddress16, 8) + "=CODE:16" }); } disassembler.setOutputOptions(sampleOptions); disassembler.setMemory(sampleMemory); disassembler.initialize(); disassembler.setOutWriter(writer); disassembler.disassembleMemRanges(); disassembler.cleanup(); listingArea.setText(""); listingArea.append(writer.toString()); listingArea.setCaretPosition(0); } catch (Exception ex) { ex.printStackTrace(); } } }; int i = 1; for (OutputOption outputOption : OutputOption.allFormatOptions) { JCheckBox checkBox = makeOutputOptionCheckBox(chip, outputOption, prefs.getOutputOptions(chip), false); if (checkBox != null) { outputOptionsCheckBoxes.add(checkBox); disassemblyOptionsPanel.add(checkBox, (i % 2 == 0) ? "wrap" : ""); checkBox.addActionListener(areaRefresherListener); i++; } } if (i % 2 == 0) { disassemblyOptionsPanel.add(new JLabel(), "wrap"); } // Force a refresh areaRefresherListener.actionPerformed(new ActionEvent(outputOptionsCheckBoxes.get(0), 0, "")); // disassemblyOptionsPanel.add(new JLabel("Sample output:", SwingConstants.LEADING), "gapbottom 1, span, split 2, aligny center"); // disassemblyOptionsPanel.add(new JSeparator(), "span 2,wrap"); disassemblyOptionsPanel.add(new JSeparator(), "span 2, gapleft rel, growx, wrap"); disassemblyOptionsPanel.add(new JLabel("Sample output:"), "span 2,wrap"); disassemblyOptionsPanel.add(new JScrollPane(listingArea), "span 2,wrap"); disassemblyOptionsPanel.add(new JLabel("Tip: hover over the option checkboxes for help"), "span 2, center, wrap"); // ------------------------ Emulation options JPanel emulationOptionsPanel = new JPanel(new VerticalLayout(5, VerticalLayout.LEFT)); emulationOptionsPanel.add(new JLabel()); JLabel warningLabel = new JLabel( "NOTE: these options only take effect after reloading the firmware (or performing a 'Stop and reset')"); warningLabel.setBackground(Color.RED); warningLabel.setOpaque(true); warningLabel.setForeground(Color.WHITE); warningLabel.setHorizontalAlignment(SwingConstants.CENTER); emulationOptionsPanel.add(warningLabel); emulationOptionsPanel.add(new JLabel()); final JCheckBox writeProtectFirmwareCheckBox = new JCheckBox("Write-protect firmware"); writeProtectFirmwareCheckBox.setSelected(prefs.isFirmwareWriteProtected(chip)); emulationOptionsPanel.add(writeProtectFirmwareCheckBox); emulationOptionsPanel.add(new JLabel( "If checked, any attempt to write to the loaded firmware area will result in an Emulator error. This can help trap spurious writes")); final JCheckBox dmaSynchronousCheckBox = new JCheckBox("Make DMA synchronous"); dmaSynchronousCheckBox.setSelected(prefs.isDmaSynchronous(chip)); emulationOptionsPanel.add(dmaSynchronousCheckBox); emulationOptionsPanel.add(new JLabel( "If checked, DMA operations will be performed immediately, pausing the CPU. Otherwise they are performed in a separate thread.")); final JCheckBox autoEnableTimersCheckBox = new JCheckBox("Auto enable timers"); autoEnableTimersCheckBox.setSelected(prefs.isAutoEnableTimers(chip)); emulationOptionsPanel.add(autoEnableTimersCheckBox); emulationOptionsPanel .add(new JLabel("If checked, timers will be automatically enabled upon reset or firmware load.")); // Log memory messages final JCheckBox logMemoryMessagesCheckBox = new JCheckBox("Log memory messages"); logMemoryMessagesCheckBox.setSelected(prefs.isLogMemoryMessages(chip)); emulationOptionsPanel.add(logMemoryMessagesCheckBox); emulationOptionsPanel .add(new JLabel("If checked, messages related to memory will be logged to the console.")); // Log serial messages final JCheckBox logSerialMessagesCheckBox = new JCheckBox("Log serial messages"); logSerialMessagesCheckBox.setSelected(prefs.isLogSerialMessages(chip)); emulationOptionsPanel.add(logSerialMessagesCheckBox); emulationOptionsPanel.add( new JLabel("If checked, messages related to serial interfaces will be logged to the console.")); // Log register messages final JCheckBox logRegisterMessagesCheckBox = new JCheckBox("Log register messages"); logRegisterMessagesCheckBox.setSelected(prefs.isLogRegisterMessages(chip)); emulationOptionsPanel.add(logRegisterMessagesCheckBox); emulationOptionsPanel.add(new JLabel( "If checked, warnings related to unimplemented register addresses will be logged to the console.")); // Log pin messages final JCheckBox logPinMessagesCheckBox = new JCheckBox("Log pin messages"); logPinMessagesCheckBox.setSelected(prefs.isLogPinMessages(chip)); emulationOptionsPanel.add(logPinMessagesCheckBox); emulationOptionsPanel.add(new JLabel( "If checked, warnings related to unimplemented I/O pins will be logged to the console.")); emulationOptionsPanel.add(new JSeparator(JSeparator.HORIZONTAL)); // Alt mode upon Debug JPanel altDebugPanel = new JPanel(new FlowLayout()); Object[] altDebugMode = EnumSet.allOf(EmulationFramework.ExecutionMode.class).toArray(); final JComboBox altModeForDebugCombo = new JComboBox(new DefaultComboBoxModel(altDebugMode)); for (int j = 0; j < altDebugMode.length; j++) { if (altDebugMode[j].equals(prefs.getAltExecutionModeForSyncedCpuUponDebug(chip))) { altModeForDebugCombo.setSelectedIndex(j); } } altDebugPanel.add(new JLabel(Constants.CHIP_LABEL[1 - chip] + " mode when " + Constants.CHIP_LABEL[chip] + " runs in sync Debug: ")); altDebugPanel.add(altModeForDebugCombo); emulationOptionsPanel.add(altDebugPanel); emulationOptionsPanel .add(new JLabel("If 'sync mode' is selected, this is the mode the " + Constants.CHIP_LABEL[1 - chip] + " chip will run in when running the " + Constants.CHIP_LABEL[chip] + " in Debug mode")); // Alt mode upon Step JPanel altStepPanel = new JPanel(new FlowLayout()); Object[] altStepMode = EnumSet.allOf(EmulationFramework.ExecutionMode.class).toArray(); final JComboBox altModeForStepCombo = new JComboBox(new DefaultComboBoxModel(altStepMode)); for (int j = 0; j < altStepMode.length; j++) { if (altStepMode[j].equals(prefs.getAltExecutionModeForSyncedCpuUponStep(chip))) { altModeForStepCombo.setSelectedIndex(j); } } altStepPanel.add(new JLabel(Constants.CHIP_LABEL[1 - chip] + " mode when " + Constants.CHIP_LABEL[chip] + " runs in sync Step: ")); altStepPanel.add(altModeForStepCombo); emulationOptionsPanel.add(altStepPanel); emulationOptionsPanel .add(new JLabel("If 'sync mode' is selected, this is the mode the " + Constants.CHIP_LABEL[1 - chip] + " chip will run in when running the " + Constants.CHIP_LABEL[chip] + " in Step mode")); // ------------------------ Prepare tabbed pane JTabbedPane tabbedPane = new JTabbedPane(); tabbedPane.addTab(Constants.CHIP_LABEL[chip] + " Disassembly Options", null, disassemblyOptionsPanel); tabbedPane.addTab(Constants.CHIP_LABEL[chip] + " Emulation Options", null, emulationOptionsPanel); if (chip == Constants.CHIP_TX) { JPanel chipSpecificOptionsPanel = new JPanel(new VerticalLayout(5, VerticalLayout.LEFT)); chipSpecificOptionsPanel.add(new JLabel("Eeprom status upon startup:")); ActionListener eepromInitializationRadioActionListener = new ActionListener() { @Override public void actionPerformed(ActionEvent e) { prefs.setEepromInitMode(Prefs.EepromInitMode.valueOf(e.getActionCommand())); } }; JRadioButton blank = new JRadioButton("Blank"); blank.setActionCommand(Prefs.EepromInitMode.BLANK.name()); blank.addActionListener(eepromInitializationRadioActionListener); if (Prefs.EepromInitMode.BLANK.equals(prefs.getEepromInitMode())) blank.setSelected(true); JRadioButton persistent = new JRadioButton("Persistent across sessions"); persistent.setActionCommand(Prefs.EepromInitMode.PERSISTENT.name()); persistent.addActionListener(eepromInitializationRadioActionListener); if (Prefs.EepromInitMode.PERSISTENT.equals(prefs.getEepromInitMode())) persistent.setSelected(true); JRadioButton lastLoaded = new JRadioButton("Last Loaded"); lastLoaded.setActionCommand(Prefs.EepromInitMode.LAST_LOADED.name()); lastLoaded.addActionListener(eepromInitializationRadioActionListener); if (Prefs.EepromInitMode.LAST_LOADED.equals(prefs.getEepromInitMode())) lastLoaded.setSelected(true); ButtonGroup group = new ButtonGroup(); group.add(blank); group.add(persistent); group.add(lastLoaded); chipSpecificOptionsPanel.add(blank); chipSpecificOptionsPanel.add(persistent); chipSpecificOptionsPanel.add(lastLoaded); chipSpecificOptionsPanel.add(new JLabel("Front panel type:")); final JComboBox frontPanelNameCombo = new JComboBox(new String[] { "D5100_small", "D5100_large" }); if (prefs.getFrontPanelName() != null) { frontPanelNameCombo.setSelectedItem(prefs.getFrontPanelName()); } frontPanelNameCombo.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { prefs.setFrontPanelName((String) frontPanelNameCombo.getSelectedItem()); } }); chipSpecificOptionsPanel.add(frontPanelNameCombo); emulationOptionsPanel.add(new JSeparator(JSeparator.HORIZONTAL)); tabbedPane.addTab(Constants.CHIP_LABEL[chip] + " specific options", null, chipSpecificOptionsPanel); } // ------------------------ Show it if (JOptionPane.OK_OPTION == JOptionPane.showOptionDialog(this, tabbedPane, Constants.CHIP_LABEL[chip] + " options", JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE, null, null, JOptionPane.DEFAULT_OPTION)) { // save output options dumpOptionCheckboxes(outputOptionsCheckBoxes, prefs.getOutputOptions(chip)); // apply TxCPUState.initRegisterLabels(prefs.getOutputOptions(chip)); // save other prefs prefs.setFirmwareWriteProtected(chip, writeProtectFirmwareCheckBox.isSelected()); prefs.setDmaSynchronous(chip, dmaSynchronousCheckBox.isSelected()); prefs.setAutoEnableTimers(chip, autoEnableTimersCheckBox.isSelected()); prefs.setLogRegisterMessages(chip, logRegisterMessagesCheckBox.isSelected()); prefs.setLogSerialMessages(chip, logSerialMessagesCheckBox.isSelected()); prefs.setLogPinMessages(chip, logPinMessagesCheckBox.isSelected()); prefs.setLogMemoryMessages(chip, logMemoryMessagesCheckBox.isSelected()); prefs.setAltExecutionModeForSyncedCpuUponDebug(chip, (EmulationFramework.ExecutionMode) altModeForDebugCombo.getSelectedItem()); prefs.setAltExecutionModeForSyncedCpuUponStep(chip, (EmulationFramework.ExecutionMode) altModeForStepCombo.getSelectedItem()); } }
From source file:ucar.unidata.idv.flythrough.Flythrough.java
/** * _more_//from ww w.ja v a 2s. c om * * @param g _more_ * @param comp _more_ */ public void paintDashboardAfter(Graphics g, JComponent comp) { Graphics2D g2 = (Graphics2D) g; AffineTransform oldTransform = g2.getTransform(); Rectangle b = dashboardLbl.getBounds(); int w = dashboardImage.getWidth(null); int h = dashboardImage.getHeight(null); Point ul = new Point(b.width / 2 - w / 2, b.height - h); int ptsIdx = 0; try { pipPanel.setPreferredSize(new Dimension(dialPts[ptsIdx][2], dialPts[ptsIdx][3])); pipFrame.setSize(dialPts[ptsIdx][2], dialPts[ptsIdx][3]); pipPanel.doLayout(); pipPanel.validate(); pipFrame.pack(); pipPanel.resetDrawBounds(); pipPanel.redraw(); } catch (Exception ignore) { } JLabel locLbl = null; if (lastLocation != null) { try { locLbl = new JLabel("<html><table width=100%><tr><td align=right> Lat:</td></td>" + getIdv().getDisplayConventions().formatLatLon(getLat(lastLocation)) + "</td></tr>" + "<tr><td align=right> Lon:</td></td>" + getIdv().getDisplayConventions().formatLatLon(getLon(lastLocation)) + "</td></tr>" + "<tr><td align=right> Alt:</td></td>" + getIdv().getDisplayConventions().formatDistance(getAlt(lastLocation)) + "</table>"); } catch (Exception ignore) { } } if (locLbl == null) { locLbl = new JLabel( "<html><table width=100%><tr><td align=right> Lat:</td></td>N/A </td></tr><tr><td align=right> Lon:</td></td>N/A </td></tr><tr><td align=right> Alt:</td></td>N/A </table>"); } locLbl.setOpaque(true); locLbl.setBackground(Color.white); DefaultValueDataset headingDataset = new DefaultValueDataset(new Double(currentHeading)); CompassPlot plot = new CompassPlot(headingDataset); plot.setSeriesNeedle(0); plot.setSeriesPaint(0, Color.red); plot.setSeriesOutlinePaint(0, Color.red); JFreeChart chart = new JFreeChart("", plot); ChartPanel compassPanel = new ChartPanel(chart); plot.setBackgroundPaint(new Color(255, 255, 255, 0)); plot.setBackgroundImageAlpha(0.0f); chart.setBackgroundPaint(new Color(255, 255, 255, 0)); compassPanel.setBackground(new Color(255, 255, 255, 0)); compassPanel.setPreferredSize(dialDimension); // compassPanel.setSize(new Dimension(100,100)); g2.setTransform(oldTransform); pipRect = drawDial(g2, pipPanel, ptsIdx++, ul); JFrame dummyFrame = new JFrame(""); dummyFrame.setContentPane(compassPanel); dummyFrame.pack(); g2.setTransform(oldTransform); drawDial(g2, compassPanel, ptsIdx++, ul); g2.setTransform(oldTransform); dummyFrame.setContentPane(locLbl); dummyFrame.pack(); drawDial(g2, locLbl, ptsIdx++, ul); if (showReadout) { for (JComponent dial : dials) { dummyFrame.setContentPane(dial); dummyFrame.pack(); g2.setTransform(oldTransform); drawDial(g2, dial, ptsIdx++, ul); } } g2.setTransform(oldTransform); }