Example usage for java.awt Color brighter

List of usage examples for java.awt Color brighter

Introduction

In this page you can find the example usage for java.awt Color brighter.

Prototype

public Color brighter() 

Source Link

Document

Creates a new Color that is a brighter version of this Color .

Usage

From source file:AppletMenuBarDemo.java

/**
 * This method is called to draw tell the component to redraw itself. If we
 * were implementing a Swing component, we'd override paintComponent()
 * instead/*www  .jav  a 2 s.  c om*/
 */
public void paint(Graphics g) {
    if (remeasure)
        measure(); // Remeasure everything first, if needed

    // Figure out Y coordinate to draw at
    Dimension size = getSize();
    int baseline = size.height - margins.bottom - descent;
    // Set the font to draw with
    g.setFont(getFont());
    // Loop through the labels
    int nummenus = labels.size();
    for (int i = 0; i < nummenus; i++) {
        // Set the drawing color. Highlight the current item
        if ((i == highlightedItem) && (highlightColor != null))
            g.setColor(getHighlightColor());
        else
            g.setColor(getForeground());

        // Draw the menu label at the position computed in measure()
        g.drawString((String) labels.elementAt(i), startPositions[i], baseline);
    }

    // Now draw a groove at the bottom of the menubar.
    Color bg = getBackground();
    g.setColor(bg.darker());
    g.drawLine(0, size.height - 2, size.width, size.height - 2);
    g.setColor(bg.brighter());
    g.drawLine(0, size.height - 1, size.width, size.height - 1);
}

From source file:canreg.client.analysis.Tools.java

public static JFreeChart generateJChart(Collection<CancerCasesCount> casesCounts, String fileName,
        String header, FileTypes fileType, ChartType chartType, boolean includeOther, boolean legendOn,
        Double restCount, Double allCount, Color color, String labelsCategoryName) {
    JFreeChart chart;//from w  w w .  j a  v  a2  s  .c om
    if (chartType == ChartType.PIE) {
        NumberFormat format = NumberFormat.getInstance();
        format.setMaximumFractionDigits(1);
        DefaultPieDataset dataset = new DefaultKeyedValuesDataset();
        int position = 0;
        for (CancerCasesCount count : casesCounts) {
            dataset.insertValue(position++,
                    count.toString() + " (" + format.format(count.getCount() / allCount * 100) + "%)",
                    count.getCount());
        }
        if (includeOther) {
            dataset.insertValue(position++,
                    "Other: " + restCount.intValue() + " (" + format.format(restCount / allCount * 100) + "%)",
                    restCount);
        }
        chart = ChartFactory.createPieChart(header, dataset, legendOn, false, Locale.getDefault());
        Tools.setPiePlotColours(chart, casesCounts.size() + 1, color.brighter());

    } else { // assume barchart
        DefaultCategoryDataset dataset = new DefaultCategoryDataset();

        for (CancerCasesCount count : casesCounts) {
            dataset.addValue(count.getCount(), count.getLabel(), count.toString());
        }
        if (includeOther) {
            dataset.addValue(restCount.intValue(), "Other", "Other: " + restCount);
        }
        chart = ChartFactory.createStackedBarChart(header, labelsCategoryName, "Cases", dataset,
                PlotOrientation.HORIZONTAL, legendOn, true, false);

        Tools.setBarPlotColours(chart, casesCounts.size() + 1, color.brighter());
    }
    return chart;
}

From source file:gov.nih.nci.caintegrator.ui.graphing.chart.plot.ClinicalPlot.java

private Color getColorForDataPoint(ClinicalDataPoint clinicalPoint) {

    String diseaseName = clinicalPoint.getDiseaseName();
    Color diseaseColor = Color.GRAY;
    Color defaultColor = Color.GRAY;
    Color retColor = Color.GRAY;

    if (diseaseName != null) {
        DiseaseType disease = DiseaseType.valueOf(diseaseName);
        diseaseColor = disease.getColor();
    }/*from w  ww.j  ava 2s.c om*/

    int grade = clinicalPoint.getDiseaseGrade();
    if (grade > 0) {
        for (int i = 0; i < grade - 1; i++) {
            diseaseColor = diseaseColor.brighter();
        }
    }
    retColor = diseaseColor;

    if (retColor == null) {
        retColor = defaultColor;
    }

    return retColor;
}

From source file:gov.nih.nci.caintegrator.ui.graphing.chart.plot.PrincipalComponentAnalysisPlot.java

/**
 * Get the color for a PCA data point. The color is determined by the Color by parameter.
 * @param pcaPoint// w w w .  j  a va  2  s .com
 * @return
 */
protected Color getColorForDataPoint(PrincipalComponentAnalysisDataPoint pcaPoint) {
    Color defaultColor = Color.GRAY;
    Color retColor = null;

    if (colorBy == PCAcolorByType.Disease) {
        String diseaseName = pcaPoint.getDiseaseName();
        Color diseaseColor = Color.GRAY;
        if (diseaseName != null) {
            DiseaseType disease = DiseaseType.valueOf(diseaseName);
            if (disease != null) {
                diseaseColor = disease.getColor();
            }
        }

        int grade = pcaPoint.getDiseaseGrade();
        for (int i = 0; i < grade - 1; i++) {
            diseaseColor = diseaseColor.brighter();
        }
        retColor = diseaseColor;
    } else if (colorBy == PCAcolorByType.Gender) {
        GenderType gender = pcaPoint.getGender();

        if (gender != null) {
            retColor = gender.getColor();
        }

    }

    if (retColor == null) {
        retColor = defaultColor;
    }

    return retColor;
}

From source file:ch.opentrainingcenter.charts.bar.OTCCategoryChartViewerTest.java

@Test
public void updateRendererMonth() {
    final Color colorNow = new Color(1, 2, 3, OTCCategoryChartViewer.ALPHA);
    when(store.getString(PreferenceConstants.CHART_DISTANCE_COLOR)).thenReturn("1,2,3");

    final JFreeChart mockedChart = mock(JFreeChart.class);
    final CategoryPlot plot = mock(CategoryPlot.class);
    when(mockedChart.getCategoryPlot()).thenReturn(plot);
    viewer.setChart(mockedChart);/*ww w  .j  a va 2 s .c  o m*/

    // Execute
    viewer.updateRenderer(XAxisChart.MONTH, TrainingChart.DISTANZ, true);

    final BarRenderer renderer = viewer.getRenderer();

    assertNotNull(renderer);
    final Color past = (Color) renderer.getSeriesPaint(1);
    assertEquals(colorNow.brighter(), past);

    final Color now = (Color) renderer.getSeriesPaint(2);
    assertEquals(colorNow, now);

    final BarPainter barPainter = renderer.getBarPainter();

    assertTrue(barPainter instanceof OTCBarPainter);

    assertEquals(0.0, renderer.getItemMargin(), 0.001);

    verify(plot).setRenderer(renderer);
}

From source file:edu.ku.brc.specify.plugins.latlon.DDDDPanel.java

/**
 * Creates the UI for the panel.//from w  w w .  j  a  va  2s. co  m
 * @param colDef the JGoodies column definition
 * @param latCols the number of columns for the latitude control
 * @param lonCols the number of columns for the longitude control
 * @param cbxIndex the column index of the combobox
 * @return return the builder
 */
protected PanelBuilder createUI(final String colDef, final int latCols, final int lonCols, final int cbxIndex,
        final boolean asDDIntegers) {
    latitudeDD = asDDIntegers ? createTextField(Integer.class, latCols, 0, 90, latTFs)
            : createTextField(Double.class, latCols, 0.0, 90.0, latTFs);
    longitudeDD = asDDIntegers ? createTextField(Integer.class, lonCols, 0, 180, lonTFs)
            : createTextField(Double.class, lonCols, 0.0, 180.0, lonTFs);
    textFields.addAll(latTFs);
    textFields.addAll(lonTFs);

    PanelBuilder builder = new PanelBuilder(new FormLayout(colDef, "p, 1px, p, c:p:g"));
    CellConstraints cc = new CellConstraints();

    latitudeDir = createDirComboxbox(true);
    longitudeDir = createDirComboxbox(false);

    JComponent latDir;
    JComponent lonDir;
    if (isViewMode) {
        latitudeDirTxt = new JTextField(2);
        longitudeDirTxt = new JTextField(2);

        setControlSize(latitudeDirTxt);
        setControlSize(longitudeDirTxt);

        ViewFactory.changeTextFieldUIForDisplay(latitudeDirTxt, false);
        ViewFactory.changeTextFieldUIForDisplay(longitudeDirTxt, false);
        latDir = latitudeDirTxt;
        lonDir = longitudeDirTxt;

    } else {
        latDir = latitudeDir;
        lonDir = longitudeDir;
    }

    builder.add(latLabel = createI18NFormLabel("Latitude", SwingConstants.RIGHT), cc.xy(1, 1));
    builder.add(latitudeDD, cc.xy(3, 1));
    builder.add(latDir, cc.xy(cbxIndex, 1));

    builder.add(lonLabel = createI18NFormLabel("Longitude", SwingConstants.RIGHT), cc.xy(1, 3));
    builder.add(longitudeDD, cc.xy(3, 3));
    builder.add(lonDir, cc.xy(cbxIndex, 3));

    builder.setBorder(BorderFactory.createEmptyBorder(4, 2, 0, 2));

    PanelBuilder pb = new PanelBuilder(new FormLayout(colDef, "p, 1px, p, p"), this);

    PanelBuilder txtPanelPB = new PanelBuilder(new FormLayout("5px,p,5px,p,2px,p", "p, 4px, p"));

    latitudeTF = new JTextField(15);
    longitudeTF = new JTextField(15);

    if (!isViewMode) {
        Color bg = getBackground();
        txtPanelPB.add(new VerticalSeparator(bg.darker(), bg.brighter()), cc.xywh(1, 1, 1, 3));
        txtPanelPB.add(latitudeTF, cc.xy(4, 1));
        txtPanelPB.add(createI18NLabel("SOURCE"), cc.xy(6, 1));
        txtPanelPB.add(longitudeTF, cc.xy(4, 3));
        txtPanelPB.add(createI18NLabel("SOURCE"), cc.xy(6, 3));
        txtPanelPB.setBorder(BorderFactory.createEmptyBorder(4, 2, 0, 2));
    }

    latitudeTF.setEditable(false);
    longitudeTF.setEditable(false);

    pb.add(builder.getPanel(), cc.xy(1, 1));
    pb.add(txtPanelPB.getPanel(), cc.xy(3, 1));

    textFields.addAll(latTFs);
    textFields.addAll(lonTFs);

    return builder;
}

From source file:lu.lippmann.cdb.graph.mouse.CadralEditingGraphMousePlugin.java

/**
 * {@inheritDoc}//from w  w  w  .  j  a v  a2s . c om
 */

@Override
public void mouseDragged(MouseEvent e) {
    if (checkModifiers(e)) {
        @SuppressWarnings("unchecked")
        final VisualizationViewer<CNode, CEdge> vv = (VisualizationViewer<CNode, CEdge>) e.getSource();
        final Layout<CNode, CEdge> layout = vv.getModel().getGraphLayout();
        final GraphElementAccessor<CNode, CEdge> pickSupport = vv.getPickSupport();
        if (startVertex != null) {
            transformEdgeShape(down, e.getPoint());
            if (edgeIsDirected == EdgeType.DIRECTED) {
                transformArrowShape(down, e.getPoint());
                final CNode pointedVertex = pickSupport.getVertex(layout, e.getX(), e.getY());
                if (pointedVertex != null && pointedVertex != startVertex) {
                    if (!pointedVertices.containsKey(pointedVertex)) {
                        pointedVertices.put(pointedVertex, pointedVertex.getColor()); //save original color
                    }
                    Color prevColor = pointedVertex.getColor();
                    if (pointedVertex.getColor().equals(pointedVertices.get(pointedVertex))) {

                        if (pointedVertex != this.lastDragVertex && this.lastDragVertex != null) {
                            lastDragVertex.setColor(pointedVertices.get(lastDragVertex));
                        }
                        //Don't change color if there is an existing edge
                        if (layout.getGraph().findEdge(startVertex, pointedVertex) == null) {
                            if (GraphUtil.isDarkNode(pointedVertex)) {
                                if (prevColor.darker().equals(prevColor)) {
                                    pointedVertex.setColor(Color.GRAY);
                                } else {
                                    if (prevColor.brighter().equals(prevColor)) {
                                        pointedVertex.setColor(Color.GRAY);
                                    } else {
                                        pointedVertex.setColor(pointedVertices.get(pointedVertex).brighter());
                                    }
                                }
                            } else {
                                pointedVertex.setColor(pointedVertices.get(pointedVertex).darker());
                            }
                        }
                    }
                    this.lastDragVertex = this.dragVertex;
                    this.dragVertex = pointedVertex;
                } else if (dragVertex != null) {
                    dragVertex.setColor(pointedVertices.get(dragVertex));
                }
            }
        }
        vv.repaint();
    }
}

From source file:edu.ku.brc.specify.ui.AppBase.java

/**
 * Shows the About dialog.//from w  w  w .j a v a2  s  .  c  om
 */
public void doAbout() {
    AppContextMgr acm = AppContextMgr.getInstance();
    boolean hasContext = acm.hasContext();

    int baseNumRows = 9;
    String serverName = AppPreferences.getLocalPrefs().get("login.servers_selected", null);
    if (serverName != null) {
        baseNumRows++;
    }

    CellConstraints cc = new CellConstraints();
    PanelBuilder infoPB = new PanelBuilder(new FormLayout("p,6px,f:p:g",
            "p,4px,p,4px," + UIHelper.createDuplicateJGoodiesDef("p", "2px", baseNumRows)));

    JLabel iconLabel = new JLabel(IconManager.getIcon("SpecifyLargeIcon"), SwingConstants.CENTER); //$NON-NLS-1$
    PanelBuilder iconPB = new PanelBuilder(new FormLayout("p", "20px,t:p,f:p:g"));
    iconPB.add(iconLabel, cc.xy(1, 2));

    if (hasContext) {
        DBTableIdMgr tableMgr = DBTableIdMgr.getInstance();
        boolean hasReged = !RegisterSpecify.isAnonymous() && RegisterSpecify.hasInstitutionRegistered();

        int y = 1;
        infoPB.addSeparator(getResourceString("Specify.SYS_INFO"), cc.xyw(1, y, 3));
        y += 2;

        JLabel lbl = UIHelper.createLabel(databaseName);
        infoPB.add(UIHelper.createI18NFormLabel("Specify.DB"), cc.xy(1, y));
        infoPB.add(lbl, cc.xy(3, y));
        y += 2;
        lbl.addMouseListener(new MouseAdapter() {
            @Override
            public void mouseClicked(MouseEvent e) {
                if (e.getClickCount() == 2) {
                    openLocalPrefs();
                }
            }
        });

        infoPB.add(UIHelper.createFormLabel(tableMgr.getTitleForId(Institution.getClassTableId())),
                cc.xy(1, y));
        infoPB.add(lbl = UIHelper.createLabel(acm.getClassObject(Institution.class).getName()), cc.xy(3, y));
        y += 2;
        lbl.addMouseListener(new MouseAdapter() {
            @Override
            public void mouseClicked(MouseEvent e) {
                if (e.getClickCount() == 2) {
                    openRemotePrefs();
                }
            }
        });
        infoPB.add(UIHelper.createFormLabel(tableMgr.getTitleForId(Division.getClassTableId())), cc.xy(1, y));
        infoPB.add(UIHelper.createLabel(acm.getClassObject(Division.class).getName()), cc.xy(3, y));
        y += 2;

        infoPB.add(UIHelper.createFormLabel(tableMgr.getTitleForId(Discipline.getClassTableId())), cc.xy(1, y));
        infoPB.add(UIHelper.createLabel(acm.getClassObject(Discipline.class).getName()), cc.xy(3, y));
        y += 2;

        infoPB.add(UIHelper.createFormLabel(tableMgr.getTitleForId(Collection.getClassTableId())), cc.xy(1, y));
        infoPB.add(UIHelper.createLabel(acm.getClassObject(Collection.class).getCollectionName()), cc.xy(3, y));
        y += 2;

        infoPB.add(UIHelper.createI18NFormLabel("Specify.BLD"), cc.xy(1, y));
        infoPB.add(UIHelper.createLabel(appBuildVersion), cc.xy(3, y));
        y += 2;

        infoPB.add(UIHelper.createI18NFormLabel("Specify.REG"), cc.xy(1, y));
        infoPB.add(UIHelper.createI18NLabel(hasReged ? "Specify.HASREG" : "Specify.NOTREG"), cc.xy(3, y));
        y += 2;

        String isaNumber = RegisterSpecify.getISANumber();
        infoPB.add(UIHelper.createI18NFormLabel("Specify.ISANUM"), cc.xy(1, y));
        infoPB.add(UIHelper.createLabel(StringUtils.isNotEmpty(isaNumber) ? isaNumber : ""), cc.xy(3, y));
        y += 2;

        if (serverName != null) {
            infoPB.add(UIHelper.createI18NFormLabel("Specify.SERVER"), cc.xy(1, y));
            infoPB.add(UIHelper.createLabel(StringUtils.isNotEmpty(serverName) ? serverName : ""), cc.xy(3, y));
            y += 2;
        }

        if (StringUtils.contains(DBConnection.getInstance().getConnectionStr(), "mysql")) {
            Vector<Object[]> list = BasicSQLUtils.query("select version() as ve");
            if (list != null && list.size() > 0) {
                infoPB.add(UIHelper.createFormLabel("MySQL Version"), cc.xy(1, y));
                infoPB.add(UIHelper.createLabel(list.get(0)[0].toString()), cc.xy(3, y));
                y += 2;
            }
        }

        infoPB.add(UIHelper.createFormLabel("Java Version"), cc.xy(1, y));
        infoPB.add(UIHelper.createLabel(System.getProperty("java.version")), cc.xy(3, y));
        y += 2;
    }

    String txt = getAboutText(appName, appVersion);
    JLabel txtLbl = createLabel(txt);
    txtLbl.setFont(UIRegistry.getDefaultFont());

    final JEditorPane txtPane = new JEditorPane("text/html", txt);
    txtPane.setEditable(false);
    txtPane.setBackground(new JPanel().getBackground());

    PanelBuilder pb = new PanelBuilder(new FormLayout("p,20px,f:min(400px;p):g,10px,8px,10px,p:g", "f:p:g"));

    pb.add(iconPB.getPanel(), cc.xy(1, 1));
    pb.add(txtPane, cc.xy(3, 1));
    Color bg = getBackground();

    if (hasContext) {
        pb.add(new VerticalSeparator(bg.darker(), bg.brighter()), cc.xy(5, 1));
        pb.add(infoPB.getPanel(), cc.xy(7, 1));
    }

    pb.setDefaultDialogBorder();

    String title = getResourceString("Specify.ABOUT");//$NON-NLS-1$
    CustomDialog aboutDlg = new CustomDialog(topFrame, title + " " + appName, true, CustomDialog.OK_BTN, //$NON-NLS-1$
            pb.getPanel());
    String okLabel = getResourceString("Specify.CLOSE");//$NON-NLS-1$
    aboutDlg.setOkLabel(okLabel);

    aboutDlg.createUI();
    aboutDlg.pack();

    // for some strange reason I can't get the dialog to size itself correctly
    Dimension size = aboutDlg.getSize();
    size.height += 120;
    aboutDlg.setSize(size);

    txtPane.addHyperlinkListener(new HyperlinkListener() {
        public void hyperlinkUpdate(HyperlinkEvent event) {
            if (event.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
                try {
                    AttachmentUtils.openURI(event.getURL().toURI());

                } catch (Exception e) {
                    edu.ku.brc.af.core.UsageTracker.incrHandledUsageCount();
                }
            }
        }
    });

    UIHelper.centerAndShow(aboutDlg);
}

From source file:edu.ku.brc.af.ui.forms.formatters.UIFormatterEditorDlg.java

@Override
public void createUI() {
    super.createUI();

    CellConstraints cc = new CellConstraints();

    orderUpBtn = createIconBtn("ReorderUp", "TCGD_MOVE_UP", new ActionListener() {
        public void actionPerformed(ActionEvent ae) {
            int inx = fieldsTbl.getSelectedRow();
            UIFieldFormatterField item = (UIFieldFormatterField) fields.get(inx);

            fields.remove(inx);//from  w w w  .j  av  a2  s  . co m
            fields.insertElementAt(item, inx - 1);
            fieldsTbl.getSelectionModel().setSelectionInterval(inx - 1, inx - 1);
            selectedFormat.resetLength();

            updateEnabledState();
            updateUIEnabled();
        }
    });
    orderDwnBtn = createIconBtn("ReorderDown", "TCGD_MOVE_DOWN", new ActionListener() {
        public void actionPerformed(ActionEvent ae) {
            int inx = fieldsTbl.getSelectedRow();
            UIFieldFormatterField item = (UIFieldFormatterField) fields.get(inx);

            fields.remove(inx);
            fields.insertElementAt(item, inx + 1);
            fieldsTbl.getSelectionModel().setSelectionInterval(inx + 1, inx + 1);
            selectedFormat.resetLength();

            updateEnabledState();
            updateUIEnabled();
        }
    });

    // get formatters for field
    List<UIFieldFormatterIFace> fmtrs = new Vector<UIFieldFormatterIFace>(uiFieldFormatterMgrCache
            .getFormatterList(fieldInfo.getTableInfo().getClassObj(), fieldInfo.getName()));
    Collections.sort(fmtrs, new Comparator<UIFieldFormatterIFace>() {
        public int compare(UIFieldFormatterIFace o1, UIFieldFormatterIFace o2) {
            return o1.toPattern().compareTo(o2.toPattern());
        }
    });

    // table and field titles
    PanelBuilder tblInfoPB = new PanelBuilder(
            new FormLayout("r:p,2px,f:p:g", "p,2px,p,2px,p,10px")/*, new FormDebugPanel()*/);

    String typeStr = fieldInfo.getType();
    typeStr = typeStr.indexOf('.') > -1 ? StringUtils.substringAfterLast(fieldInfo.getType(), ".") : typeStr;

    JLabel tableTitleLbl = createI18NFormLabel("FFE_TABLE");
    JLabel tableTitleValueLbl = createLabel(fieldInfo.getTableInfo().getTitle());
    tableTitleValueLbl.setBackground(Color.WHITE);
    tableTitleValueLbl.setOpaque(true);

    JLabel fieldTitleLbl = createI18NFormLabel("FFE_FIELD");
    JLabel fieldTitleValueLbl = createLabel(fieldInfo.getTitle());
    fieldTitleValueLbl.setBackground(Color.WHITE);
    fieldTitleValueLbl.setOpaque(true);

    JLabel fieldLengthLbl = createI18NFormLabel("FFE_LENGTH");
    JLabel fieldLengthValueLbl = createLabel(Integer.toString(fieldInfo.getLength()));
    fieldLengthValueLbl.setBackground(Color.WHITE);
    fieldLengthValueLbl.setOpaque(true);

    int y = 1;
    tblInfoPB.add(tableTitleLbl, cc.xy(1, y));
    tblInfoPB.add(tableTitleValueLbl, cc.xy(3, y));
    y += 2;
    tblInfoPB.add(fieldTitleLbl, cc.xy(1, y));
    tblInfoPB.add(fieldTitleValueLbl, cc.xy(3, y));
    y += 2;
    tblInfoPB.add(fieldLengthLbl, cc.xy(1, y));
    tblInfoPB.add(fieldLengthValueLbl, cc.xy(3, y));
    y += 2;

    // sample panel
    sampleLabel = createLabel("", SwingConstants.LEFT);
    JPanel samplePanel = new JPanel();
    samplePanel.setBorder(BorderFactory.createTitledBorder(getResourceString("FFE_SAMPLE"))); //$NON-NLS-1$ 
    samplePanel.add(sampleLabel);

    // name text field
    nameTF = createTextField(20);

    // title text field
    titleTF = createTextField(20);

    byYearCB = createCheckBox(getResourceString("FFE_BY_YEAR_CHECKBOX")); //$NON-NLS-1$ 
    hookByYearCheckBoxListener();

    fieldsPanel = new EditDeleteAddPanel(getSaveAL(), getDelAL(), getAddAL());
    fieldsTbl = new JTable(fieldsModel = new FieldsTableModel());
    fieldTypeCbx = new JComboBox(FieldType.values()); // I18N
    fieldTxt = createTextField(20);
    fieldsPanel.getAddBtn().setEnabled(true);
    fieldsPanel.getEditBtn().setIcon(IconManager.getIcon("Green Arrow Up", IconManager.IconSize.Std16));
    UIHelper.makeTableHeadersCentered(fieldsTbl, true);

    fieldTxt.setDocument(new FieldDocument());

    fieldsTbl.getSelectionModel().setSelectionMode(ListSelectionModel.SINGLE_SELECTION);

    int width = fieldTypeCbx.getPreferredSize().width;

    y = 1;
    PanelBuilder subPB = new PanelBuilder(new FormLayout("r:p,2px,p", "p,4px, p,4px, p,4px, p,4px"));

    subPB.add(createI18NFormLabel("FFE_NAME"), cc.xy(1, y));
    subPB.add(nameTF, cc.xy(3, y));
    y += 2;

    subPB.add(createI18NFormLabel("FFE_TITLE"), cc.xy(1, y));
    subPB.add(titleTF, cc.xy(3, y));
    y += 2;

    subPB.add(byYearCB, cc.xy(3, y));
    y += 2;

    // CardLayout for Editor Panels

    SpinnerModel retModel = new SpinnerNumberModel(1, //initial value
            1, //min
            fieldInfo.getLength(), //max
            1); //step
    sizeSpinner = new JSpinner(retModel);
    isIncChk = new JCheckBox("Is Incrementer"); // I18N

    String colDefs = "f:p:g,p,2px," + width + "px,2px,p";

    closeBtn = createClose(0);
    PanelBuilder numPB = new PanelBuilder(new FormLayout(colDefs, "p,2px,p,2px,p"));
    numPB.add(createI18NFormLabel("FFE_LENGTH"), cc.xy(2, 1));
    numPB.add(sizeSpinner, cc.xy(4, 1));
    //numPB.add(closeBtn,    cc.xy(6, 1));
    numPB.add(isIncChk, cc.xy(4, 3));

    sepCbx = new JComboBox(new String[] { "-", ".", "/", "(space)", "_" });
    closeBtn = createClose(1);
    PanelBuilder sepPB = new PanelBuilder(new FormLayout(colDefs, "p,2px,p"));
    sepPB.add(createI18NFormLabel("FFE_SEP"), cc.xy(2, 1));
    sepPB.add(sepCbx, cc.xy(4, 1));
    //sepPB.add(closeBtn, cc.xy(6, 1));

    closeBtn = createClose(2);
    PanelBuilder txtPB = new PanelBuilder(new FormLayout(colDefs, "p,2px,p"));
    txtPB.add(createI18NFormLabel("FFE_TEXT"), cc.xy(2, 1));
    txtPB.add(fieldTxt, cc.xy(4, 1));

    cardPanel = new JPanel(cardLayout);
    cardPanel.add("size", numPB.getPanel());
    cardPanel.add("text", txtPB.getPanel());
    cardPanel.add("sep", sepPB.getPanel());
    cardPanel.add("none", new JLabel(" "));

    y = 1;
    PanelBuilder leftPB = new PanelBuilder(new FormLayout("f:p:g", "t:p,10px,p,f:p:g"));
    leftPB.add(tblInfoPB.getPanel(), cc.xy(1, y));
    y += 2;
    leftPB.add(subPB.getPanel(), cc.xy(1, y));
    y += 2;

    PanelBuilder upDownPanel = new PanelBuilder(new FormLayout("p", "f:p:g, p, 2px, p, f:p:g"));
    upDownPanel.add(orderUpBtn, cc.xy(1, 2));
    upDownPanel.add(orderDwnBtn, cc.xy(1, 4));

    totLenLbl = createLabel("XXXXX");

    y = 1;
    PanelBuilder rightPB = new PanelBuilder(new FormLayout("p:g,2px,p,2px,p", "200px,2px,p,2px,p,2px,p"));
    rightPB.add(createScrollPane(fieldsTbl), cc.xywh(1, y, 3, 1));
    rightPB.add(upDownPanel.getPanel(), cc.xywh(5, y, 1, 1));
    y += 2;
    rightPB.add(totLenLbl, cc.xy(1, y));
    rightPB.add(fieldsPanel, cc.xywh(3, y, 1, 1));
    y += 2;
    rightPB.add(fieldTypeLbl = createI18NFormLabel("FFE_TYPE"), cc.xy(1, y));
    rightPB.add(fieldTypeCbx, cc.xy(3, y));
    rightPB.add(closeBtn, cc.xy(5, y));
    y += 2;
    rightPB.add(cardPanel, cc.xyw(1, y, 3));
    y += 2;

    y = 1;
    PanelBuilder pb = new PanelBuilder(new FormLayout("p:g,10px,p,10px,p:g,10px,p", "f:p:g,10px,p"));
    Color bg = getBackground();
    pb.add(new VerticalSeparator(bg.darker(), bg.brighter()), cc.xywh(3, 1, 1, 1));

    pb.add(leftPB.getPanel(), cc.xy(1, y));
    pb.add(rightPB.getPanel(), cc.xy(5, y));
    //pb.add(keyPanel,             cc.xy(7, y));     
    y += 2;
    pb.add(samplePanel, cc.xyw(1, y, 7));
    y += 2;

    setByYearSelected(selectedFormat);

    nameTF.setEditable(isNew);
    nameTF.setText(selectedFormat.getName());
    titleTF.setText(selectedFormat.getTitle());
    updateSample();

    hookTextChangeListener(nameTF, "FFE_NO_NAME", 32);
    hookTextChangeListener(titleTF, "FFE_NO_TITLE", 32);

    pb.setDefaultDialogBorder();

    contentPanel = pb.getPanel();
    mainPanel.add(contentPanel, BorderLayout.CENTER);

    updateUIEnabled();

    pack();

    enabledEditorUI(false);

    hookFieldsTblSelectionListener();

    fieldTypeCbx.addItemListener(new ItemListener() {
        @Override
        public void itemStateChanged(ItemEvent e) {
            typeChanged();
        }
    });

    sepCbx.addItemListener(new ItemListener() {
        @Override
        public void itemStateChanged(ItemEvent e) {
            fieldHasChanged = true;
            updateEnabledState();
            hasChanged = true;
            updateUIEnabled();
        }
    });

    fieldTxt.getDocument().addDocumentListener(new DocumentAdaptor() {
        @Override
        protected void changed(DocumentEvent e) {
            fieldHasChanged = true;
            updateEnabledState();
            hasChanged = true;
            updateUIEnabled();
        }
    });

    sizeSpinner.addChangeListener(new ChangeListener() {
        @Override
        public void stateChanged(ChangeEvent e) {
            fieldHasChanged = true;
            updateEnabledState();
            hasChanged = true;
            updateUIEnabled();

        }
    });

    isIncChk.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            fieldHasChanged = true;
            if (!isIncChk.isSelected()) {
                byYearCB.setSelected(false);
            }
            updateEntry();
            updateUIEnabled();
            updateEnabledState();
            fieldsTbl.repaint();
        }
    });

    fieldTypeCbx.setSelectedIndex(-1);
    fieldHasChanged = false;
    updateEnabledState();
}

From source file:edu.ku.brc.specify.Specify.java

/**
 * Shows the About dialog./*from   w w w. jav  a2 s.com*/
 */
public void doAbout() {
    AppContextMgr acm = AppContextMgr.getInstance();
    boolean showDetailedAbout = acm.hasContext() && acm.getClassObject(Division.class) != null
            && acm.getClassObject(Discipline.class) != null && acm.getClassObject(Collection.class) != null;

    int baseNumRows = 14;
    String serverName = AppPreferences.getLocalPrefs().get("login.servers_selected", null);
    if (serverName != null) {
        baseNumRows++;
    }

    CellConstraints cc = new CellConstraints();
    PanelBuilder infoPB = new PanelBuilder(new FormLayout("p,6px,f:p:g",
            "p,4px,p,4px," + UIHelper.createDuplicateJGoodiesDef("p", "2px", baseNumRows)));

    JLabel iconLabel = new JLabel(IconManager.getIcon("SpecifyLargeIcon"), SwingConstants.CENTER); //$NON-NLS-1$
    PanelBuilder iconPB = new PanelBuilder(new FormLayout("p", "20px,t:p,f:p:g"));
    iconPB.add(iconLabel, cc.xy(1, 2));

    if (showDetailedAbout) {
        final ArrayList<String> values = new ArrayList<String>();

        DBTableIdMgr tableMgr = DBTableIdMgr.getInstance();
        boolean hasReged = !RegisterSpecify.isAnonymous() && RegisterSpecify.hasInstitutionRegistered();

        int y = 1;
        infoPB.addSeparator(getResourceString("Specify.SYS_INFO"), cc.xyw(1, y, 3));
        y += 2;

        JLabel lbl = UIHelper.createLabel(databaseName);
        addLabel(values, infoPB, UIHelper.createI18NFormLabel("Specify.DB"), cc.xy(1, y));
        addLabel(values, infoPB, lbl, cc.xy(3, y));
        y += 2;
        lbl.addMouseListener(new MouseAdapter() {
            @Override
            public void mouseClicked(MouseEvent e) {
                if (e.getClickCount() == 2) {
                    openLocalPrefs();
                }
            }
        });

        int instId = Institution.getClassTableId();
        addLabel(values, infoPB, UIHelper.createFormLabel(tableMgr.getTitleForId(instId)), cc.xy(1, y));
        addLabel(values, infoPB, lbl = UIHelper.createLabel(acm.getClassObject(Institution.class).getName()),
                cc.xy(3, y));
        y += 2;

        addLabel(values, infoPB, UIHelper.createFormLabel(getGUIDTitle(instId)), cc.xy(1, y));

        String noGUID = "<No GUID>";
        String guidStr = acm.getClassObject(Institution.class).getGuid();
        addLabel(values, infoPB, lbl = UIHelper.createLabel(guidStr != null ? guidStr : noGUID), cc.xy(3, y));
        y += 2;

        lbl.addMouseListener(new MouseAdapter() {
            @Override
            public void mouseClicked(MouseEvent e) {
                if (e.getClickCount() == 2) {
                    openRemotePrefs();
                }
            }
        });
        addLabel(values, infoPB, UIHelper.createFormLabel(tableMgr.getTitleForId(Division.getClassTableId())),
                cc.xy(1, y));
        addLabel(values, infoPB, lbl = UIHelper.createLabel(acm.getClassObject(Division.class).getName()),
                cc.xy(3, y));
        y += 2;
        lbl.addMouseListener(new MouseAdapter() {
            @Override
            public void mouseClicked(MouseEvent e) {
                if (e.getClickCount() == 2) {
                    openGlobalPrefs();
                }
            }
        });

        addLabel(values, infoPB, UIHelper.createFormLabel(tableMgr.getTitleForId(Discipline.getClassTableId())),
                cc.xy(1, y));
        addLabel(values, infoPB, UIHelper.createLabel(acm.getClassObject(Discipline.class).getName()),
                cc.xy(3, y));
        y += 2;

        addLabel(values, infoPB, UIHelper.createFormLabel(tableMgr.getTitleForId(Collection.getClassTableId())),
                cc.xy(1, y));
        addLabel(values, infoPB, UIHelper.createLabel(acm.getClassObject(Collection.class).getCollectionName()),
                cc.xy(3, y));
        y += 2;
        addLabel(values, infoPB, UIHelper.createFormLabel(getGUIDTitle(Collection.getClassTableId())),
                cc.xy(1, y));

        guidStr = acm.getClassObject(Collection.class).getGuid();
        addLabel(values, infoPB, UIHelper.createLabel(guidStr != null ? guidStr : noGUID), cc.xy(3, y));
        y += 2;
        //addLabel(values, infoPB, UIHelper.createI18NFormLabel("Specify.BLD"), cc.xy(1, y));
        //addLabel(values, infoPB, UIHelper.createLabel(appBuildVersion),cc.xy(3, y)); y += 2;

        addLabel(values, infoPB, UIHelper.createI18NFormLabel("Specify.BLD"), cc.xy(1, y));
        UIRegistry.loadAndPushResourceBundle("bld");
        addLabel(values, infoPB, UIHelper.createLabel(getResourceString("build")), cc.xy(3, y));
        y += 2;

        addLabel(values, infoPB, UIHelper.createI18NFormLabel("Specify.BLD_TM"), cc.xy(1, y));
        addLabel(values, infoPB, UIHelper.createLabel(getResourceString("buildtime")), cc.xy(3, y));
        y += 2;
        UIRegistry.popResourceBundle();

        addLabel(values, infoPB, UIHelper.createI18NFormLabel("Specify.REG"), cc.xy(1, y));
        addLabel(values, infoPB, UIHelper.createI18NLabel(hasReged ? "Specify.HASREG" : "Specify.NOTREG"),
                cc.xy(3, y));
        y += 2;

        String isaNumber = RegisterSpecify.getISANumber();
        addLabel(values, infoPB, UIHelper.createI18NFormLabel("Specify.ISANUM"), cc.xy(1, y));
        addLabel(values, infoPB, UIHelper.createLabel(StringUtils.isNotEmpty(isaNumber) ? isaNumber : ""),
                cc.xy(3, y));
        y += 2;

        if (serverName != null) {
            addLabel(values, infoPB, UIHelper.createI18NFormLabel("Specify.SERVER"), cc.xy(1, y));
            addLabel(values, infoPB, UIHelper.createLabel(StringUtils.isNotEmpty(serverName) ? serverName : ""),
                    cc.xy(3, y));
            y += 2;
        }

        if (StringUtils.contains(DBConnection.getInstance().getConnectionStr(), "mysql")) {
            Vector<Object[]> list = BasicSQLUtils.query("select version() as ve");
            if (list != null && list.size() > 0) {
                addLabel(values, infoPB, UIHelper.createFormLabel("MySQL Version"), cc.xy(1, y));
                addLabel(values, infoPB, UIHelper.createLabel(list.get(0)[0].toString()), cc.xy(3, y));
                y += 2;
            }
        }

        addLabel(values, infoPB, UIHelper.createFormLabel("Java Version"), cc.xy(1, y));
        addLabel(values, infoPB, UIHelper.createLabel(System.getProperty("java.version")), cc.xy(3, y));
        y += 2;

        JButton copyCBBtn = createIconBtn("ClipboardCopy", IconManager.IconSize.Std24, "Specify.CPY_ABT_TO_TT",
                null);
        //copyCBBtn.setBackground(Color.WHITE);
        //copyCBBtn.setOpaque(true);
        //copyCBBtn.setBorder(BorderFactory.createEtchedBorder());

        copyCBBtn.setEnabled(true);

        PanelBuilder cbPB = new PanelBuilder(new FormLayout("f:p:g,p", "p"));
        cbPB.add(copyCBBtn, cc.xy(2, 1));
        copyCBBtn.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                // Copy to Clipboard
                StringBuilder sb = new StringBuilder();
                for (int i = 0; i < values.size(); i++) {
                    sb.append(String.format("%s = %s\n", values.get(i), values.get(i + 1)));
                    i++;
                }
                UIHelper.setTextToClipboard(sb.toString());
                UIRegistry.displayInfoMsgDlgLocalized("Specify.CPY_ABT_TO_MSG");
            }
        });
        infoPB.add(cbPB.getPanel(), cc.xy(3, y));
        y += 2;
    }

    String txt = getAboutText(appName, appVersion);
    JLabel txtLbl = createLabel(txt);
    txtLbl.setFont(UIRegistry.getDefaultFont());

    final JEditorPane txtPane = new JEditorPane("text/html", txt);
    txtPane.setEditable(false);
    txtPane.setBackground(new JPanel().getBackground());

    PanelBuilder pb = new PanelBuilder(new FormLayout("p,20px,f:min(400px;p):g,10px,8px,10px,p:g", "f:p:g"));

    pb.add(iconPB.getPanel(), cc.xy(1, 1));
    pb.add(txtPane, cc.xy(3, 1));
    Color bg = getBackground();

    if (showDetailedAbout) {
        pb.add(new VerticalSeparator(bg.darker(), bg.brighter()), cc.xy(5, 1));
        pb.add(infoPB.getPanel(), cc.xy(7, 1));
    }

    pb.setDefaultDialogBorder();

    String title = getResourceString("Specify.ABOUT");//$NON-NLS-1$
    CustomDialog aboutDlg = new CustomDialog(topFrame, title + " " + appName, true, CustomDialog.OK_BTN, //$NON-NLS-1$
            pb.getPanel());
    String okLabel = getResourceString("Specify.CLOSE");//$NON-NLS-1$
    aboutDlg.setOkLabel(okLabel);

    aboutDlg.createUI();
    aboutDlg.pack();

    // for some strange reason I can't get the dialog to size itself correctly
    Dimension size = aboutDlg.getSize();
    size.height += 120;
    aboutDlg.setSize(size);

    txtPane.addHyperlinkListener(new HyperlinkListener() {
        public void hyperlinkUpdate(HyperlinkEvent event) {
            if (event.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
                try {
                    AttachmentUtils.openURI(event.getURL().toURI());

                } catch (Exception e) {
                    edu.ku.brc.af.core.UsageTracker.incrHandledUsageCount();
                }
            }
        }
    });

    UIHelper.centerAndShow(aboutDlg);
}