Example usage for java.awt Color LIGHT_GRAY

List of usage examples for java.awt Color LIGHT_GRAY

Introduction

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

Prototype

Color LIGHT_GRAY

To view the source code for java.awt Color LIGHT_GRAY.

Click Source Link

Document

The color light gray.

Usage

From source file:net.nikr.eve.jeveasset.gui.tabs.tracker.TrackerTab.java

public TrackerTab(Program program) {
    super(program, TabsTracker.get().title(), Images.TOOL_TRACKER.getIcon(), true);

    filterDialog = new TrackerFilterDialog(program);

    jPopupMenu = new JPopupMenu();
    jPopupMenu.addPopupMenuListener(listener);

    JMenuItem jMenuItem;/*from w  w  w. j  av a 2  s.  c o  m*/
    jMenuItem = new JMenuItem(TabsTracker.get().edit(), Images.EDIT_EDIT.getIcon());
    jMenuItem.setActionCommand(TrackerAction.EDIT.name());
    jMenuItem.addActionListener(listener);
    jPopupMenu.add(jMenuItem);

    jMenuItem = new JMenuItem(TabsTracker.get().delete(), Images.EDIT_DELETE.getIcon());
    jMenuItem.setActionCommand(TrackerAction.DELETE.name());
    jMenuItem.addActionListener(listener);
    jPopupMenu.add(jMenuItem);

    JMenuInfo.createDefault(jPopupMenu);

    jIskValue = new JMenuItem();
    jIskValue.setEnabled(false);
    jIskValue.setForeground(Color.BLACK);
    jIskValue.setHorizontalAlignment(SwingConstants.RIGHT);
    jIskValue.setDisabledIcon(Images.TOOL_VALUES.getIcon());
    jPopupMenu.add(jIskValue);

    jDateValue = new JMenuItem();
    jDateValue.setEnabled(false);
    jDateValue.setForeground(Color.BLACK);
    jDateValue.setHorizontalAlignment(SwingConstants.RIGHT);
    jPopupMenu.add(jDateValue);

    jEditDialog = new JTrackerEditDialog(program);

    jSelectionDialog = new JSelectionDialog(program);

    JSeparator jDateSeparator = new JSeparator();

    jQuickDate = new JComboBox<QuickDate>(QuickDate.values());
    jQuickDate.setActionCommand(TrackerAction.QUICK_DATE.name());
    jQuickDate.addActionListener(listener);

    JLabel jFromLabel = new JLabel(TabsTracker.get().from());
    jFrom = createDateChooser();

    JLabel jToLabel = new JLabel(TabsTracker.get().to());
    jTo = createDateChooser();

    jAll = new JCheckBox(General.get().all());
    jAll.setSelected(true);
    jAll.setActionCommand(TrackerAction.ALL.name());
    jAll.addActionListener(listener);
    jAll.setFont(new Font(jAll.getFont().getName(), Font.ITALIC, jAll.getFont().getSize()));

    jTotal = new JCheckBox(TabsTracker.get().total());
    jTotal.setSelected(true);
    jTotal.setActionCommand(TrackerAction.UPDATE_SHOWN.name());
    jTotal.addActionListener(listener);

    jWalletBalance = new JCheckBox(TabsTracker.get().walletBalance());
    jWalletBalance.setSelected(true);
    jWalletBalance.setActionCommand(TrackerAction.UPDATE_SHOWN.name());
    jWalletBalance.addActionListener(listener);

    jWalletBalanceFilters = new JButton(Images.LOC_INCLUDE.getIcon());
    jWalletBalanceFilters.setActionCommand(TrackerAction.FILTER_WALLET_BALANCE.name());
    jWalletBalanceFilters.addActionListener(listener);

    jAssets = new JCheckBox(TabsTracker.get().assets());
    jAssets.setSelected(true);
    jAssets.setActionCommand(TrackerAction.UPDATE_SHOWN.name());
    jAssets.addActionListener(listener);

    jAssetsFilters = new JButton(Images.LOC_INCLUDE.getIcon());
    jAssetsFilters.setActionCommand(TrackerAction.FILTER_ASSETS.name());
    jAssetsFilters.addActionListener(listener);

    jSellOrders = new JCheckBox(TabsTracker.get().sellOrders());
    jSellOrders.setSelected(true);
    jSellOrders.setActionCommand(TrackerAction.UPDATE_SHOWN.name());
    jSellOrders.addActionListener(listener);

    jEscrows = new JCheckBox(TabsTracker.get().escrows());
    jEscrows.setSelected(true);
    jEscrows.setActionCommand(TrackerAction.UPDATE_SHOWN.name());
    jEscrows.addActionListener(listener);

    jEscrowsToCover = new JCheckBox(TabsTracker.get().escrowsToCover());
    jEscrowsToCover.setSelected(true);
    jEscrowsToCover.setActionCommand(TrackerAction.UPDATE_SHOWN.name());
    jEscrowsToCover.addActionListener(listener);

    jManufacturing = new JCheckBox(TabsTracker.get().manufacturing());
    jManufacturing.setSelected(true);
    jManufacturing.setActionCommand(TrackerAction.UPDATE_SHOWN.name());
    jManufacturing.addActionListener(listener);

    jContractCollateral = new JCheckBox(TabsTracker.get().contractCollateral());
    jContractCollateral.setSelected(true);
    jContractCollateral.setActionCommand(TrackerAction.UPDATE_SHOWN.name());
    jContractCollateral.addActionListener(listener);

    jContractValue = new JCheckBox(TabsTracker.get().contractValue());
    jContractValue.setSelected(true);
    jContractValue.setActionCommand(TrackerAction.UPDATE_SHOWN.name());
    jContractValue.addActionListener(listener);

    JSeparator jOwnersSeparator = new JSeparator();

    jAllProfiles = new JCheckBox(TabsTracker.get().allProfiles());
    jAllProfiles.setActionCommand(TrackerAction.PROFILE.name());
    jAllProfiles.addActionListener(listener);

    jOwners = new JMultiSelectionList<String>();
    jOwners.getSelectionModel().addListSelectionListener(listener);
    JScrollPane jOwnersScroll = new JScrollPane(jOwners);

    JLabel jHelp = new JLabel(TabsTracker.get().help());
    jHelp.setIcon(Images.MISC_HELP.getIcon());

    JLabel jNoFilter = new JLabel(TabsTracker.get().helpLegacyData());
    jNoFilter.setIcon(new ShapeIcon(NO_FILTER));

    JLabel jFilter = new JLabel(TabsTracker.get().helpNewData());
    jFilter.setIcon(new ShapeIcon(FILTER_AND_DEFAULT));

    JDropDownButton jSettings = new JDropDownButton(Images.DIALOG_SETTINGS.getIcon());

    jIncludeZero = new JCheckBoxMenuItem(TabsTracker.get().includeZero());
    jIncludeZero.setSelected(true);
    jIncludeZero.setActionCommand(TrackerAction.INCLUDE_ZERO.name());
    jIncludeZero.addActionListener(listener);
    jSettings.add(jIncludeZero);

    DateAxis domainAxis = new DateAxis();
    domainAxis.setDateFormatOverride(dateFormat);
    domainAxis.setVerticalTickLabels(true);
    domainAxis.setAutoTickUnitSelection(true);
    domainAxis.setAutoRange(true);
    domainAxis.setTickLabelFont(jFromLabel.getFont());

    NumberAxis rangeAxis = new NumberAxis();
    rangeAxis.setAutoRange(true);
    rangeAxis.setStandardTickUnits(NumberAxis.createStandardTickUnits());
    rangeAxis.setTickLabelFont(jFromLabel.getFont());

    //XYPlot plot = new XYPlot(dataset, domainAxis, rangeAxis, new XYLineAndShapeRenderer(true, true));
    render = new MyRender();
    XYPlot plot = new XYPlot(dataset, domainAxis, rangeAxis, render);
    plot.setBackgroundPaint(Color.WHITE);
    plot.setRangeGridlinePaint(Color.LIGHT_GRAY);
    plot.setDomainGridlinePaint(Color.LIGHT_GRAY);
    plot.getRenderer()
            .setBaseToolTipGenerator(new StandardXYToolTipGenerator("{0}: {2} ({1})", dateFormat, iskFormat));
    plot.setDomainCrosshairLockedOnData(true);
    plot.setDomainCrosshairStroke(new BasicStroke(1));
    plot.setDomainCrosshairPaint(Color.BLACK);
    plot.setDomainCrosshairVisible(false);
    plot.setRangeCrosshairLockedOnData(true);
    plot.setRangeCrosshairVisible(false);

    jNextChart = new JFreeChart(plot);
    jNextChart.setAntiAlias(true);
    jNextChart.setBackgroundPaint(jPanel.getBackground());
    jNextChart.addProgressListener(null);
    jNextChart.getLegend().setItemFont(jFrom.getFont());

    jChartPanel = new ChartPanel(jNextChart);
    jChartPanel.addMouseListener(listener);
    jChartPanel.setDomainZoomable(false);
    jChartPanel.setRangeZoomable(false);
    jChartPanel.setPopupMenu(null);
    jChartPanel.addChartMouseListener(listener);
    jChartPanel.setMaximumDrawHeight(Integer.MAX_VALUE);
    jChartPanel.setMaximumDrawWidth(Integer.MAX_VALUE);
    jChartPanel.setMinimumDrawWidth(10);
    jChartPanel.setMinimumDrawHeight(10);

    int AssetsGapWidth = PANEL_WIDTH - jAssets.getPreferredSize().width
            - jAssetsFilters.getPreferredSize().width;
    if (AssetsGapWidth < 0) {
        AssetsGapWidth = 0;
    }
    int WalletGapWidth = PANEL_WIDTH - jWalletBalance.getPreferredSize().width
            - jWalletBalanceFilters.getPreferredSize().width;
    if (WalletGapWidth < 0) {
        WalletGapWidth = 0;
    }

    layout.setHorizontalGroup(layout.createSequentialGroup().addGroup(layout.createParallelGroup()
            .addGroup(layout.createSequentialGroup().addComponent(jHelp).addGap(20).addComponent(jNoFilter)
                    .addGap(20).addComponent(jFilter).addGap(20, 20, Integer.MAX_VALUE).addComponent(jSettings)
                    .addGap(6))
            .addComponent(jChartPanel)).addGroup(
                    layout.createParallelGroup().addComponent(jQuickDate, PANEL_WIDTH, PANEL_WIDTH, PANEL_WIDTH)
                            .addGroup(layout.createSequentialGroup()
                                    .addGroup(layout.createParallelGroup()
                                            .addComponent(jFromLabel, LABEL_WIDTH, LABEL_WIDTH, LABEL_WIDTH)
                                            .addComponent(jToLabel, LABEL_WIDTH, LABEL_WIDTH, LABEL_WIDTH))
                                    .addGap(0)
                                    .addGroup(layout.createParallelGroup()
                                            .addComponent(jFrom, PANEL_WIDTH - LABEL_WIDTH,
                                                    PANEL_WIDTH - LABEL_WIDTH, PANEL_WIDTH - LABEL_WIDTH)
                                            .addComponent(jTo, PANEL_WIDTH - LABEL_WIDTH,
                                                    PANEL_WIDTH - LABEL_WIDTH, PANEL_WIDTH - LABEL_WIDTH)))
                            .addComponent(jDateSeparator, PANEL_WIDTH, PANEL_WIDTH, PANEL_WIDTH)
                            .addComponent(jAll, PANEL_WIDTH, PANEL_WIDTH, PANEL_WIDTH)
                            .addComponent(jTotal, PANEL_WIDTH, PANEL_WIDTH, PANEL_WIDTH)
                            .addGroup(layout.createSequentialGroup().addComponent(jWalletBalance)
                                    .addGap(0, 0, WalletGapWidth).addComponent(jWalletBalanceFilters))
                            .addGroup(layout.createSequentialGroup().addComponent(jAssets)
                                    .addGap(0, 0, AssetsGapWidth).addComponent(jAssetsFilters))
                            .addComponent(jSellOrders, PANEL_WIDTH, PANEL_WIDTH, PANEL_WIDTH)
                            .addComponent(jEscrows, PANEL_WIDTH, PANEL_WIDTH, PANEL_WIDTH)
                            .addComponent(jEscrowsToCover, PANEL_WIDTH, PANEL_WIDTH, PANEL_WIDTH)
                            .addComponent(jManufacturing, PANEL_WIDTH, PANEL_WIDTH, PANEL_WIDTH)
                            .addComponent(jContractCollateral, PANEL_WIDTH, PANEL_WIDTH, PANEL_WIDTH)
                            .addComponent(jContractValue, PANEL_WIDTH, PANEL_WIDTH, PANEL_WIDTH)
                            .addComponent(jOwnersSeparator, PANEL_WIDTH, PANEL_WIDTH, PANEL_WIDTH)
                            .addComponent(jAllProfiles, PANEL_WIDTH, PANEL_WIDTH, PANEL_WIDTH)
                            .addComponent(jOwnersScroll, PANEL_WIDTH, PANEL_WIDTH, PANEL_WIDTH)));
    layout.setVerticalGroup(layout.createParallelGroup()
            .addGroup(layout.createSequentialGroup().addGroup(layout.createParallelGroup()
                    .addComponent(jHelp, Program.getButtonsHeight(), Program.getButtonsHeight(),
                            Program.getButtonsHeight())
                    .addComponent(jNoFilter, Program.getButtonsHeight(), Program.getButtonsHeight(),
                            Program.getButtonsHeight())
                    .addComponent(jFilter, Program.getButtonsHeight(), Program.getButtonsHeight(),
                            Program.getButtonsHeight())
                    .addComponent(jSettings, Program.getButtonsHeight(), Program.getButtonsHeight(),
                            Program.getButtonsHeight()))
                    .addComponent(jChartPanel))
            .addGroup(layout.createSequentialGroup()
                    .addComponent(jQuickDate, Program.getButtonsHeight(), Program.getButtonsHeight(),
                            Program.getButtonsHeight())
                    .addGroup(layout.createParallelGroup()
                            .addComponent(jFromLabel, Program.getButtonsHeight(), Program.getButtonsHeight(),
                                    Program.getButtonsHeight())
                            .addComponent(jFrom, Program.getButtonsHeight(), Program.getButtonsHeight(),
                                    Program.getButtonsHeight()))
                    .addGroup(layout.createParallelGroup()
                            .addComponent(jToLabel, Program.getButtonsHeight(), Program.getButtonsHeight(),
                                    Program.getButtonsHeight())
                            .addComponent(jTo, Program.getButtonsHeight(), Program.getButtonsHeight(),
                                    Program.getButtonsHeight()))
                    .addComponent(jDateSeparator, 3, 3, 3)
                    .addComponent(jAll, Program.getButtonsHeight(), Program.getButtonsHeight(),
                            Program.getButtonsHeight())
                    .addComponent(jTotal, Program.getButtonsHeight(), Program.getButtonsHeight(),
                            Program.getButtonsHeight())
                    .addGroup(layout.createParallelGroup()
                            .addComponent(jWalletBalance, Program.getButtonsHeight(),
                                    Program.getButtonsHeight(), Program.getButtonsHeight())
                            .addComponent(jWalletBalanceFilters, Program.getButtonsHeight(),
                                    Program.getButtonsHeight(), Program.getButtonsHeight()))
                    .addGroup(layout.createParallelGroup()
                            .addComponent(jAssets, Program.getButtonsHeight(), Program.getButtonsHeight(),
                                    Program.getButtonsHeight())
                            .addComponent(jAssetsFilters, Program.getButtonsHeight(),
                                    Program.getButtonsHeight(), Program.getButtonsHeight()))
                    .addComponent(jSellOrders, Program.getButtonsHeight(), Program.getButtonsHeight(),
                            Program.getButtonsHeight())
                    .addComponent(jEscrows, Program.getButtonsHeight(), Program.getButtonsHeight(),
                            Program.getButtonsHeight())
                    .addComponent(jEscrowsToCover, Program.getButtonsHeight(), Program.getButtonsHeight(),
                            Program.getButtonsHeight())
                    .addComponent(jManufacturing, Program.getButtonsHeight(), Program.getButtonsHeight(),
                            Program.getButtonsHeight())
                    .addComponent(jContractCollateral, Program.getButtonsHeight(), Program.getButtonsHeight(),
                            Program.getButtonsHeight())
                    .addComponent(jContractValue, Program.getButtonsHeight(), Program.getButtonsHeight(),
                            Program.getButtonsHeight())
                    .addComponent(jOwnersSeparator, 3, 3, 3)
                    .addComponent(jAllProfiles, Program.getButtonsHeight(), Program.getButtonsHeight(),
                            Program.getButtonsHeight())
                    .addComponent(jOwnersScroll, 70, 70, Integer.MAX_VALUE)));
}

From source file:com.jd.survey.web.pdf.SurveyPdf.java

private void writeAnswersMatrix(Document document, Question question, Boolean[][] answerValuesMatrix,
        String falseMessage, String trueMessage) throws Exception {
    Table matrixTable;/* w  w w.  j  a va2  s .c  o m*/
    Cell cell;

    Paragraph questionParagraph = new Paragraph();
    questionParagraph.add(new Chunk(question.getQuestionText().trim() + ": ", boldedFont));
    document.add(questionParagraph);

    matrixTable = new Table(question.getColumnLabels().size() + 1);
    matrixTable.setPadding(2);
    matrixTable.setWidth(100);
    matrixTable.setDefaultCellBorder(0);
    matrixTable.setBorder(0);

    matrixTable.setOffset(4);

    matrixTable.setAutoFillEmptyCells(true);
    matrixTable.setCellsFitPage(true);

    matrixTable.setTableFitsPage(true);
    cell = new Cell("");
    cell.setBackgroundColor(Color.LIGHT_GRAY);
    matrixTable.addCell(cell);

    for (QuestionColumnLabel questionColumnLabel : question.getColumnLabels()) {
        cell = new Cell(new Paragraph(questionColumnLabel.getLabel(), boldedFont));
        cell.setBackgroundColor(Color.LIGHT_GRAY);
        matrixTable.addCell(cell);
    }
    int rowIndex = 0;
    for (QuestionRowLabel questionRowLabel : question.getRowLabels()) {
        int columnIndex = 0;
        questionParagraph = new Paragraph(questionRowLabel.getLabel(), boldedFont);
        questionParagraph.setLeading(12, 0);
        cell = new Cell(questionParagraph);
        if ((rowIndex % 2) == 1) {
            cell.setBackgroundColor(new Color(231, 238, 244));
        }
        matrixTable.addCell(cell);
        for (QuestionColumnLabel questionColumnLabel : question.getColumnLabels()) {
            questionParagraph = new Paragraph(
                    answerValuesMatrix[rowIndex][columnIndex] ? trueMessage : falseMessage, normalFont);
            questionParagraph.setLeading(12, 0);
            cell = new Cell(questionParagraph);
            if ((rowIndex % 2) == 1) {
                cell.setBackgroundColor(new Color(231, 238, 244));
            }
            matrixTable.addCell(cell);
            columnIndex++;
        }
        rowIndex++;
    }
    document.add(matrixTable);
}

From source file:edu.ku.brc.stats.StatGroupTable.java

/**
 * Overrides paint to draw in name at top with separator AND the Label
 *//* ww  w. j  a  v  a  2s  .c  o m*/
public void paint(Graphics g) {
    super.paint(g);

    if (!useSeparator) {
        Dimension dim = getSize();

        FontMetrics fm = g.getFontMetrics();
        int strW = fm.stringWidth(name);

        int x = (dim.width - strW) / 2;
        Insets ins = getBorder().getBorderInsets(this);
        int y = 2 + fm.getAscent();

        int lineW = dim.width - ins.left - ins.right;
        g.setColor(Color.BLUE.darker());
        g.drawString(name, x, y);
        x = ins.left;
        y += fm.getDescent() + fm.getLeading();

        g.setColor(Color.LIGHT_GRAY.brighter());
        g.drawLine(x, y, x + lineW, y);
        y++;
        x++;
        g.setColor(Color.LIGHT_GRAY);
        g.drawLine(x, y, x + lineW, y);
    }
}

From source file:org.yccheok.jstock.charting.Utils.java

/**
 * Applying chart theme based on given JFreeChart.
 *
 * @param chart the JFreeChart/*from   w  w w  . ja v a2  s .c  o  m*/
 */
public static void applyChartTheme(JFreeChart chart) {
    final StandardChartTheme chartTheme = (StandardChartTheme) org.jfree.chart.StandardChartTheme
            .createJFreeTheme();
    chartTheme.setXYBarPainter(barPainter);
    chartTheme.setShadowVisible(false);
    chartTheme.setPlotBackgroundPaint(Color.WHITE);
    chartTheme.setDomainGridlinePaint(Color.LIGHT_GRAY);
    chartTheme.setRangeGridlinePaint(Color.LIGHT_GRAY);
    chartTheme.setPlotOutlinePaint(Color.LIGHT_GRAY);

    // The default font used by JFreeChart unable to render Chinese properly.
    // We need to provide font which is able to support Chinese rendering.
    final Locale defaultLocale = Locale.getDefault();
    if (org.yccheok.jstock.gui.Utils.isSimplifiedChinese(defaultLocale)
            || org.yccheok.jstock.gui.Utils.isTraditionalChinese(defaultLocale)) {
        final Font oldExtraLargeFont = chartTheme.getExtraLargeFont();
        final Font oldLargeFont = chartTheme.getLargeFont();
        final Font oldRegularFont = chartTheme.getRegularFont();
        final Font oldSmallFont = chartTheme.getSmallFont();

        final Font extraLargeFont = new Font("Sans-serif", oldExtraLargeFont.getStyle(),
                oldExtraLargeFont.getSize());
        final Font largeFont = new Font("Sans-serif", oldLargeFont.getStyle(), oldLargeFont.getSize());
        final Font regularFont = new Font("Sans-serif", oldRegularFont.getStyle(), oldRegularFont.getSize());
        final Font smallFont = new Font("Sans-serif", oldSmallFont.getStyle(), oldSmallFont.getSize());

        chartTheme.setExtraLargeFont(extraLargeFont);
        chartTheme.setLargeFont(largeFont);
        chartTheme.setRegularFont(regularFont);
        chartTheme.setSmallFont(smallFont);
    }

    if (chart.getPlot() instanceof CombinedDomainXYPlot) {
        @SuppressWarnings("unchecked")
        List<Plot> plots = ((CombinedDomainXYPlot) chart.getPlot()).getSubplots();
        for (Plot plot : plots) {
            final int domainAxisCount = ((XYPlot) plot).getDomainAxisCount();
            final int rangeAxisCount = ((XYPlot) plot).getRangeAxisCount();
            for (int i = 0; i < domainAxisCount; i++) {
                ((XYPlot) plot).getDomainAxis(i).setAxisLinePaint(Color.LIGHT_GRAY);
                ((XYPlot) plot).getDomainAxis(i).setTickMarkPaint(Color.LIGHT_GRAY);
            }
            for (int i = 0; i < rangeAxisCount; i++) {
                ((XYPlot) plot).getRangeAxis(i).setAxisLinePaint(Color.LIGHT_GRAY);
                ((XYPlot) plot).getRangeAxis(i).setTickMarkPaint(Color.LIGHT_GRAY);
            }
        }
    } else {
        final Plot plot = chart.getPlot();
        if (plot instanceof XYPlot) {
            final org.jfree.chart.plot.XYPlot xyPlot = (org.jfree.chart.plot.XYPlot) plot;
            final int domainAxisCount = xyPlot.getDomainAxisCount();
            final int rangeAxisCount = xyPlot.getRangeAxisCount();
            for (int i = 0; i < domainAxisCount; i++) {
                xyPlot.getDomainAxis(i).setAxisLinePaint(Color.LIGHT_GRAY);
                xyPlot.getDomainAxis(i).setTickMarkPaint(Color.LIGHT_GRAY);
            }
            for (int i = 0; i < rangeAxisCount; i++) {
                xyPlot.getRangeAxis(i).setAxisLinePaint(Color.LIGHT_GRAY);
                xyPlot.getRangeAxis(i).setTickMarkPaint(Color.LIGHT_GRAY);
            }
        }
        //else if (plot instanceof org.jfree.chart.plot.PiePlot) {
        //    final org.jfree.chart.plot.PiePlot piePlot = (org.jfree.chart.plot.PiePlot)plot;
        //    
        //}
    }

    chartTheme.apply(chart);
}

From source file:com.graphhopper.jsprit.analysis.toolbox.Plotter.java

private XYPlot createPlot(final XYSeriesCollection problem, XYSeriesCollection shipments,
        XYSeriesCollection solution) {/*from w  w  w  .j a v a 2s .  co  m*/
    XYPlot plot = new XYPlot();
    plot.setBackgroundPaint(Color.LIGHT_GRAY);
    plot.setRangeGridlinePaint(Color.LIGHT_GRAY);
    plot.setDomainGridlinePaint(Color.LIGHT_GRAY);

    XYLineAndShapeRenderer problemRenderer = getProblemRenderer(problem);
    plot.setDataset(0, problem);
    plot.setRenderer(0, problemRenderer);

    XYItemRenderer shipmentsRenderer = getShipmentRenderer(shipments);
    plot.setDataset(1, shipments);
    plot.setRenderer(1, shipmentsRenderer);

    if (solution != null) {
        XYItemRenderer solutionRenderer = getRouteRenderer(solution);
        plot.setDataset(2, solution);
        plot.setRenderer(2, solutionRenderer);
    }

    NumberAxis xAxis = new NumberAxis();
    NumberAxis yAxis = new NumberAxis();

    if (boundingBox == null) {
        xAxis.setRangeWithMargins(getDomainRange(problem));
        yAxis.setRangeWithMargins(getRange(problem));
    } else {
        xAxis.setRangeWithMargins(new Range(boundingBox.minX, boundingBox.maxX));
        yAxis.setRangeWithMargins(new Range(boundingBox.minY, boundingBox.maxY));
    }

    plot.setDomainAxis(xAxis);
    plot.setRangeAxis(yAxis);

    return plot;
}

From source file:edu.ku.brc.specify.plugins.ipadexporter.ManageDataSetsDlg.java

/**
 * //from ww w  .j  a  va  2 s.  c  o  m
 */
private void addUserToDS() {
    final Vector<String> wsList = new Vector<String>();
    final Vector<String> instItems = new Vector<String>();

    String addStr = getResourceString("ADD");
    instItems.add(addStr);
    wsList.add(addStr);
    for (String fullName : cloudHelper.getInstList()) {
        String[] toks = StringUtils.split(fullName, '\t');
        instItems.add(toks[0]);
        wsList.add(toks[1]);
    }

    final JTextField userNameTF = createTextField(20);
    final JTextField passwordTF = createTextField(20);
    final JLabel pwdLbl = createI18NFormLabel("Password");
    final JLabel statusLbl = createLabel("");
    final JCheckBox isNewUser = UIHelper.createCheckBox("Is New User");
    final JLabel instLbl = createI18NFormLabel("Insitution");
    final JComboBox instCmbx = UIHelper.createComboBox(instItems.toArray());

    if (instItems.size() == 2) {
        instCmbx.setSelectedIndex(1);
    }

    CellConstraints cc = new CellConstraints();
    PanelBuilder pb = new PanelBuilder(new FormLayout("p,2px,f:p:g", "p,4px,p,4px,p,4px,p,4px,p,8px,p"));

    pb.add(createI18NLabel("Add New or Existing User to DataSet"), cc.xyw(1, 1, 3));
    pb.add(createI18NFormLabel("Username"), cc.xy(1, 3));
    pb.add(userNameTF, cc.xy(3, 3));
    pb.add(pwdLbl, cc.xy(1, 5));
    pb.add(passwordTF, cc.xy(3, 5));
    pb.add(instLbl, cc.xy(1, 7));
    pb.add(instCmbx, cc.xy(3, 7));

    pb.add(isNewUser, cc.xy(3, 9));

    pb.add(statusLbl, cc.xyw(1, 11, 3));
    pb.setDefaultDialogBorder();

    pwdLbl.setVisible(false);
    passwordTF.setVisible(false);
    instLbl.setVisible(false);
    instCmbx.setVisible(false);

    final CustomDialog dlg = new CustomDialog(this, "Add User", true, OKCANCEL, pb.getPanel()) {
        @Override
        protected void okButtonPressed() {
            String usrName = userNameTF.getText();
            if (cloudHelper.isUserNameOK(usrName)) {
                String collGuid = datasetGUIDList.get(dataSetList.getSelectedIndex());
                if (cloudHelper.addUserAccessToDataSet(usrName, collGuid)) {
                    super.okButtonPressed();
                } else {
                    iPadDBExporterPlugin.setErrorMsg(statusLbl,
                            String.format("Unable to add usr: %s to the DataSet guid: %s", usrName, collGuid));
                }
            } else if (isNewUser.isSelected()) {
                String pwdStr = passwordTF.getText();
                String guid = null;
                if (instCmbx.getSelectedIndex() == 0) {
                    //                        InstDlg instDlg = new InstDlg(cloudHelper);
                    //                        if (!instDlg.isInstOK())
                    //                        {
                    //                            instDlg.createUI();
                    //                            instDlg.pack();
                    //                            centerAndShow(instDlg, 600, null);
                    //                            if (instDlg.isCancelled())
                    //                            {
                    //                                return;
                    //                            }
                    //                            //guid = instDlg.getGuid()();
                    //                        }
                } else {
                    //webSite = wsList.get(instCmbx.getSelectedIndex());

                }

                if (guid != null) {
                    String collGuid = datasetGUIDList.get(dataSetList.getSelectedIndex());
                    if (cloudHelper.addNewUser(usrName, pwdStr, guid)) {
                        if (cloudHelper.addUserAccessToDataSet(usrName, collGuid)) {
                            ManageDataSetsDlg.this.loadUsersForDataSetsIntoJList();
                            super.okButtonPressed();
                        } else {
                            iPadDBExporterPlugin.setErrorMsg(statusLbl,
                                    String.format("Unable to add%s to the DataSet %s", usrName, collGuid));
                        }
                    } else {
                        iPadDBExporterPlugin.setErrorMsg(statusLbl,
                                String.format("Unable to add%s to the DataSet %s", usrName, collGuid));
                    }
                } else {
                    // error
                }
            } else {
                iPadDBExporterPlugin.setErrorMsg(statusLbl, String.format("'%s' doesn't exist.", usrName));
            }
        }
    };

    KeyAdapter ka = new KeyAdapter() {
        @Override
        public void keyPressed(KeyEvent e) {
            statusLbl.setText("");
            String usrNmStr = userNameTF.getText();
            boolean hasData = StringUtils.isNotEmpty(usrNmStr)
                    && (!isNewUser.isSelected() || StringUtils.isNotEmpty(passwordTF.getText()))
                    && UIHelper.isValidEmailAddress(usrNmStr);
            dlg.getOkBtn().setEnabled(hasData);
        }

    };
    userNameTF.addKeyListener(ka);
    passwordTF.addKeyListener(ka);

    final Color textColor = userNameTF.getForeground();

    FocusAdapter fa = new FocusAdapter() {
        @Override
        public void focusGained(FocusEvent e) {
            JTextField tf = (JTextField) e.getSource();
            if (!tf.getForeground().equals(textColor)) {
                tf.setText("");
                tf.setForeground(textColor);
            }
        }

        @Override
        public void focusLost(FocusEvent e) {
            JTextField tf = (JTextField) e.getSource();
            if (tf.getText().length() == 0) {
                tf.setText("Enter email address");
                tf.setForeground(Color.LIGHT_GRAY);
            }
        }
    };
    userNameTF.addFocusListener(fa);

    userNameTF.setText("Enter email address");
    userNameTF.setForeground(Color.LIGHT_GRAY);

    isNewUser.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            boolean isSel = isNewUser.isSelected();
            pwdLbl.setVisible(isSel);
            passwordTF.setVisible(isSel);
            instLbl.setVisible(isSel);
            instCmbx.setVisible(isSel);

            Dimension s = dlg.getSize();
            int hgt = isNewUser.getSize().height + 4 + instCmbx.getSize().height;
            s.height += isSel ? hgt : -hgt;
            dlg.setSize(s);
        }
    });

    dlg.createUI();
    dlg.getOkBtn().setEnabled(false);

    centerAndShow(dlg);
    if (!dlg.isCancelled()) {
        loadUsersForDataSetsIntoJList();
    }
}

From source file:eu.ggnet.dwoss.misc.op.listings.SalesListingProducerOperation.java

/**
 * Generates XLS files for units in a specific sales channel.
 * The lists are seperated by brand.//ww w.j  a v  a  2  s . com
 * <p>
 * @param channel the saleschannel
 * @return XLS files for units in a specific sales channel.
 */
private Map<TradeName, Collection<FileJacket>> generateXlsListings(SalesChannel channel) {
    SubMonitor m = monitorFactory.newSubMonitor("Listen fr " + channel.getName() + " erstellen", 100);
    m.start();
    List<StockUnit> stockUnits = new StockUnitEao(stockEm).findByNoLogicTransactionAndPresentStock();
    List<UniqueUnit> uniqueUnits = new UniqueUnitEao(uuEm).findByIds(toUniqueUnitIds(stockUnits));

    Map<TradeName, List<UniqueUnit>> units = uniqueUnits.stream()
            .collect(Collectors.groupingBy(uu -> uu.getProduct().getTradeName()));

    m.worked(2, "prfe und filtere Gerte");
    Map<TradeName, Collection<FileJacket>> files = new HashMap<>();

    for (TradeName k : units.keySet()) {
        List<UniqueUnit> uus = units.get(k);
        Collections.sort(uus, new UniqueUnitComparator());
        List<Object[]> rows = new ArrayList<>();
        for (UniqueUnit get : uus) {
            UniqueUnit uu = get;
            Product p = uu.getProduct();

            // Cases to filter out.
            if (uu.getSalesChannel() != channel)
                continue;
            if (!uu.hasPrice((channel == SalesChannel.CUSTOMER ? PriceType.CUSTOMER : PriceType.RETAILER)))
                continue;

            Object[] row = { uu.getRefurbishId(), p.getPartNo(), p.getGroup().getNote(),
                    p.getTradeName().getName(), p.getName(), p.getDescription(), uu.getWarranty().getName(),
                    uu.getWarrentyValid(), UniqueUnitFormater.toSingleLineAccessories(uu),
                    uu.getCondition().getNote(), UniqueUnitFormater.toSingleLineComment(uu),
                    uu.getPrice(PriceType.RETAILER), uu.getPrice(PriceType.CUSTOMER),
                    (!uu.hasPrice(PriceType.CUSTOMER) ? null
                            : MathUtil.roundedApply(uu.getPrice(PriceType.CUSTOMER), GlobalConfig.TAX, 0)), };
            rows.add(row);
        }
        if (rows.isEmpty())
            continue;

        m.worked(5, "creating File, Gerte: " + rows.size());

        STable unitTable = new STable();
        unitTable.setTableFormat(
                new CFormat(CENTER, TOP, new CBorder(Color.GRAY, CBorder.LineStyle.THIN), true));
        unitTable.setHeadlineFormat(
                new CFormat(CFormat.FontStyle.BOLD, Color.BLACK, Color.LIGHT_GRAY, CENTER, MIDDLE));
        unitTable.setRowHeight(1000);

        unitTable.add(new STableColumn("SopoNr", 12));
        unitTable.add(new STableColumn("ArtikelNr", 15));
        unitTable.add(new STableColumn("Warengruppe", 18));
        unitTable.add(new STableColumn("Hersteller", 15));
        unitTable.add(new STableColumn("Bezeichnung", 30));
        unitTable.add(new STableColumn("Beschreibung", 60, LFT));
        unitTable.add(new STableColumn("Garantie", 18, LFT));
        unitTable.add(new STableColumn("Garantie bis", 18, new CFormat(Representation.SHORT_DATE)));
        unitTable.add(new STableColumn("Zubehr", 30, LFT));
        unitTable.add(new STableColumn("optische Bewertung", 25));
        unitTable.add(new STableColumn("Bemerkung", 50, LFT));
        unitTable.add(new STableColumn("Hndler", 15, EURO));
        unitTable.add(new STableColumn("Endkunde", 15, EURO));
        unitTable.add(new STableColumn("E.inc.Mwst", 15, EURO));
        unitTable.setModel(new STableModelList(rows));

        CCalcDocument cdoc = new TempCalcDocument();
        cdoc.add(new CSheet("Sonderposten", unitTable));
        files.put(k, Arrays.asList(new FileJacket(k.getName() + " Liste", ".xls",
                LucidCalc.createWriter(LucidCalc.Backend.XLS).write(cdoc))));
    }
    m.finish();
    return files;
}

From source file:org.fhcrc.cpl.viewer.quant.gui.PanelWithSpectrumChart.java

License:asdf

/**
 *  Generate all the charts/*from  w w  w.  j  a  v a2  s.  co m*/
 */
public void generateCharts() {
    int minScanIndex = Math.abs(run.getIndexForScanNum(minScan));
    int maxScanIndex = Math.abs(run.getIndexForScanNum(maxScan));
    int numScans = maxScanIndex - minScanIndex + 1;
    int numMzBins = (int) ((float) resolution * (maxMz - minMz)) + 1;
    double[] scanValues = new double[numScans];

    double[] mzValues = new double[numMzBins];

    for (int i = 0; i < numScans; i++)
        scanValues[i] = run.getScanNumForIndex(minScanIndex + i);
    for (int i = 0; i < numMzBins; i++)
        mzValues[i] = minMz + (i / (float) resolution);

    //Resampling adds some slop on each end
    float minMzForRange = (int) minMz;
    if (minMzForRange > minMz)
        minMzForRange--;
    float maxMzForRange = (int) maxMz;
    if (maxMzForRange < maxMz)
        maxMzForRange++;

    FloatRange mzWindowForResample = new FloatRange(minMzForRange, maxMzForRange);
    double[][] intensityValues = new double[numScans][numMzBins];
    _log.debug("Loading spectrum in range....");

    double[] sumIntensitiesInQuantRange = new double[numMzBins];
    //carry just the intensities used in quantitation
    double[] sumPeakIntensitiesInQuantRange = new double[numMzBins];
    if (numSafePeaks < 0)
        numSafePeaks = Math.min(Math.round((heavyMz - lightMz) * charge), MAX_Q3_PEAKS);
    if (heavyMz < lightMz)
        numSafePeaks = 4;
    if (peakMzs != null)
        numSafePeaks = Math.min(numSafePeaks, peakMzs.length);

    List<Float> peakMzsToQuantitate = new ArrayList<Float>();
    List<Float> nonMonoisotopicPeakMzList = new ArrayList<Float>();

    for (int i = 0; i < numSafePeaks; i++) {
        float lightPeakMz = lightMz + (peakSeparationMass / charge) * i;
        float heavyPeakMz = heavyMz + (peakSeparationMass / charge) * i;
        if (peakMzs != null) {
            lightPeakMz = peakMzs[i];
            heavyPeakMz = heavyMz + (lightPeakMz - lightMz);
        }
        peakMzsToQuantitate.add(lightPeakMz);
        peakMzsToQuantitate.add(heavyPeakMz);
        nonMonoisotopicPeakMzList.add(lightPeakMz);
        if (heavyPeakMz > lightMz)
            nonMonoisotopicPeakMzList.add(heavyPeakMz);
    }
    int heavyMonoisotopicPeakIndex = numSafePeaks;

    float[] nonMonoisotopicPeakMzs = new float[nonMonoisotopicPeakMzList.size()];
    for (int i = 0; i < nonMonoisotopicPeakMzs.length; i++) {
        nonMonoisotopicPeakMzs[i] = nonMonoisotopicPeakMzList.get(i);
    }
    Collections.sort(peakMzsToQuantitate);

    //dhmay adding 20090723
    //For calculating single-peak ratio based on theoretical highest peak
    int maxIdealPeakIndex = Spectrum.calcMaxIdealPeakIndex(lightMz - Spectrum.HYDROGEN_ION_MASS) * charge;
    float lightMaxIdealPeakIntensitySum = 0f;
    float heavyMaxIdealPeakIntensitySum = 0f;

    for (int scanArrayIndex = 0; scanArrayIndex < numScans; scanArrayIndex++) {
        int scanIndex = minScanIndex + scanArrayIndex;
        MSRun.MSScan scan = run.getScan(scanIndex);
        if (scan.getNum() == idEventScan)
            specifiedScanFoundMS1 = true;
        float[] signalFromResample = Spectrum.Resample(scan.getSpectrum(), mzWindowForResample, resolution);
        int firstIndexToKeep = -1;

        for (int i = 0; i < signalFromResample.length; i++) {
            float mzValueThisIndex = minMzForRange + (i / (float) resolution);
            if (mzValueThisIndex >= minMz && firstIndexToKeep == -1) {
                firstIndexToKeep = i;
                break;
            }
        }

        //this is horrible.  arraycopy would be better, but need to convert float to double
        double[] signal = new double[numMzBins];
        for (int i = 0; i < numMzBins; i++) {
            signal[i] = signalFromResample[firstIndexToKeep + i];

        }

        if (shouldGenerateLineCharts) {
            double[] signalPeaks = new double[numMzBins];
            int currentPeakIndex = -1;
            float minMzCurrentPeak = -1;
            float maxMzCurrentPeak = -1;
            for (int i = 0; i < numMzBins; i++) {
                double mz = mzValues[i];
                if (mz > maxMzCurrentPeak && currentPeakIndex < peakMzsToQuantitate.size() - 1) {
                    currentPeakIndex++;
                    float currentPeakMz = peakMzsToQuantitate.get(currentPeakIndex);
                    float currentPeakMass = (currentPeakMz - Spectrum.HYDROGEN_ION_MASS) * charge;
                    float deltaMz = (peakTolerancePPM * currentPeakMass / 1000000f) / charge;
                    minMzCurrentPeak = currentPeakMz - deltaMz;
                    maxMzCurrentPeak = currentPeakMz + deltaMz;
                }
                if (mz >= minMzCurrentPeak && mz <= maxMzCurrentPeak) {
                    signalPeaks[i] += signal[i];
                }
            }
            upperZBoundNearPeak = Math.max(upperZBoundNearPeak, BasicStatistics.max(signalPeaks));

            PanelWithLineChart lineChart = new PanelWithPeakChart(mzValues, signalPeaks,
                    "Scan " + (int) scanValues[scanArrayIndex], PanelWithLineChart.defaultShape, Color.BLUE);
            lineChart.addData(mzValues, signal, "all", PanelWithLineChart.defaultShape, Color.GRAY);

            lineChart.setAxisLabels("m/z", "intensity");
            scanLineChartMap.put((int) scanValues[scanArrayIndex], lineChart);
        }

        intensityValues[scanArrayIndex] = signal;

        upperZBound = Math.max(upperZBound, BasicStatistics.max(signal));

        if (scan.getNum() >= lightFirstScanLine && scan.getNum() >= heavyFirstScanLine
                && scan.getNum() <= lightLastScanLine && scan.getNum() <= heavyLastScanLine) {
            int currentPeakIndex = -1;
            float minMzCurrentPeak = -1;
            float maxMzCurrentPeak = -1;
            for (int i = 0; i < sumIntensitiesInQuantRange.length; i++) {
                sumIntensitiesInQuantRange[i] += signal[i];
                float mz = (float) mzValues[i];

                if (mz > maxMzCurrentPeak && currentPeakIndex < peakMzsToQuantitate.size() - 1) {
                    currentPeakIndex++;
                    float currentPeakMz = peakMzsToQuantitate.get(currentPeakIndex);
                    float currentPeakMass = (currentPeakMz - Spectrum.HYDROGEN_ION_MASS) * charge;
                    float deltaMz = (peakTolerancePPM * currentPeakMass / 1000000f) / charge;
                    minMzCurrentPeak = currentPeakMz - deltaMz;
                    maxMzCurrentPeak = currentPeakMz + deltaMz;
                }

                if (mz >= minMzCurrentPeak && mz <= maxMzCurrentPeak) {
                    sumPeakIntensitiesInQuantRange[i] += signal[i];
                    //dhmay adding 20090723 for single-peak quantitation
                    if (currentPeakIndex == maxIdealPeakIndex)
                        lightMaxIdealPeakIntensitySum += signal[i];
                    else if (currentPeakIndex == heavyMonoisotopicPeakIndex + maxIdealPeakIndex)
                        heavyMaxIdealPeakIntensitySum += signal[i];
                }
            }
        }
    }

    ratioOnePeak = lightMaxIdealPeakIntensitySum / Math.max(heavyMaxIdealPeakIntensitySum, 0.001f);

    double maxIntensityOnSumChart = BasicStatistics.max(sumIntensitiesInQuantRange);
    double maxPeakIntensity = BasicStatistics.max(sumPeakIntensitiesInQuantRange);
    if (maxIntensityOnSumChart < 1)
        maxIntensityOnSumChart = maxPeakIntensity;

    float[] monoisotopicMzs = new float[] { lightMz, heavyMz };

    double intensityForSumChartHeight = maxIntensityOnSumChart * 1.5;
    float[] monoisotopicIntensitiesSumChart = new float[] { (float) intensityForSumChartHeight,
            (float) intensityForSumChartHeight };
    intensitySumChart = new PanelWithPeakChart(mzValues, sumPeakIntensitiesInQuantRange, "Peak Intensities");

    intensitySumChart.addData(mzValues, sumIntensitiesInQuantRange, "Intensity Sum",
            PanelWithLineChart.defaultShape, Color.LIGHT_GRAY);
    if (heavyMz > 0)
        intensitySumChart.addDataFloat(monoisotopicMzs, monoisotopicIntensitiesSumChart,
                "Monoisotopic light and heavy", PanelWithLineChart.defaultShape, Color.GREEN);
    else
        intensitySumChart.addDataFloat(new float[] { lightMz },
                new float[] { (float) intensityForSumChartHeight }, "Monoisotopic light and heavy",
                PanelWithLineChart.defaultShape, Color.GREEN);
    if (nonMonoisotopicPeakMzs.length > 0) {
        //for (float mz : nonMonoisotopicPeakMzs) System.err.println("***" + mz);
        float[] nonmonoisotopicIntensitiesSumChart = new float[nonMonoisotopicPeakMzs.length];
        Arrays.fill(nonmonoisotopicIntensitiesSumChart, (float) intensityForSumChartHeight);
        //System.err.println("ADDING LINES, peakMzs null ? " + (peakMzs == null));            
        if (peakMzs != null) {
            intensitySumChart.addDataFloat(nonMonoisotopicPeakMzs, nonmonoisotopicIntensitiesSumChart,
                    "Nonmonoisotopic light and heavy (exact)", PanelWithLineChart.defaultShape, Color.RED);
        } else {
            intensitySumChart.addDataFloat(nonMonoisotopicPeakMzs, nonmonoisotopicIntensitiesSumChart,
                    "Nonmonoisotopic light and heavy (approx)", PanelWithLineChart.defaultShape, Color.ORANGE);

        }
    }
    intensitySumChart.getChart().removeLegend();
    intensitySumChart.setAxisLabels("m/z", "Intensity (Sum)");
    if (maxPeakIntensity > 1)
        ((XYPlot) intensitySumChart.getPlot()).getRangeAxis().setRange(0, maxPeakIntensity * 1.25);
    intensitySumChart.setSize(getWidth(), getHeight());

    if (shouldGenerateLineCharts) {
        float rangeMax = (float) upperZBoundNearPeak * 1.25f;
        for (PanelWithLineChart lineChart : scanLineChartMap.values()) {
            ((XYPlot) lineChart.getPlot()).getRangeAxis().setRange(0, rangeMax);
            float[] monoisotopicIntensities = new float[] { (float) rangeMax, rangeMax };
            lineChart.addDataFloat(monoisotopicMzs, monoisotopicIntensities, "Monoisotopic light and heavy",
                    PanelWithLineChart.defaultShape, Color.GREEN);
            if (nonMonoisotopicPeakMzs.length > 0) {
                float[] nonMonoisotopicIntensities = new float[nonMonoisotopicPeakMzs.length];
                Arrays.fill(nonMonoisotopicIntensities, rangeMax);
                lineChart.addDataFloat(nonMonoisotopicPeakMzs, nonMonoisotopicIntensities,
                        "Nonmonoisotopic light and heavy", PanelWithLineChart.defaultShape, Color.ORANGE);
            }
            lineChart.getChart().removeLegend();
        }
    }

    int lightFirstScanLineIndex = -1;
    int lightLastScanLineIndex = -1;
    int heavyFirstScanLineIndex = -1;
    int heavyLastScanLineIndex = -1;

    int numScansPadded = maxScan - minScan + 1;
    double[] scanValuesPadded;
    double[][] intensityValuesPadded;
    setPaintScale(createHeatMapPaintScale());

    if (numScansPadded == numScans) {
        scanValuesPadded = scanValues;
        intensityValuesPadded = intensityValues;

        if (lightFirstScanLine > 0) {
            for (int i = 0; i < scanValues.length; i++) {
                if (scanValues[i] < lightFirstScanLine)
                    lightFirstScanLineIndex = i;
                else
                    break;
            }
        }
        if (lightLastScanLine > 0) {
            for (int i = 0; i < scanValues.length; i++) {
                if (scanValues[i] <= lightLastScanLine + 1)
                    lightLastScanLineIndex = i;
                else
                    break;
            }
        }
        if (heavyFirstScanLine > 0) {
            for (int i = 0; i < scanValues.length; i++) {
                if (scanValues[i] < heavyFirstScanLine)
                    heavyFirstScanLineIndex = i;
                else
                    break;
            }
        }
        if (heavyLastScanLine > 0) {
            for (int i = 0; i < scanValues.length; i++) {
                if (scanValues[i] <= heavyLastScanLine + 1)
                    heavyLastScanLineIndex = i;
                else
                    break;
            }
        }
    } else {
        _log.debug("Padding! unpadded: " + numScans + ", padded: " + numScansPadded);

        scanValuesPadded = new double[numScansPadded];
        intensityValuesPadded = new double[numScansPadded][numMzBins];

        int unPaddedIndex = 0;

        for (int i = 0; i < scanValuesPadded.length; i++) {
            int scanValue = minScan + i;
            scanValuesPadded[i] = scanValue;

            if (unPaddedIndex < scanValues.length - 1 && scanValue >= scanValues[unPaddedIndex + 1])
                unPaddedIndex++;

            System.arraycopy(intensityValues[unPaddedIndex], 0, intensityValuesPadded[i], 0,
                    intensityValues[unPaddedIndex].length);
        }

        //add the lines for the scanlines, just outside the specified boundaries
        if (lightFirstScanLine > 0) {
            lightFirstScanLineIndex = 0;
            for (int i = 0; i < scanValuesPadded.length; i++) {
                if (scanValuesPadded[i] < lightFirstScanLine) {
                    lightFirstScanLineIndex = i;
                } else
                    break;
            }
        }
        if (lightLastScanLine > 0) {
            lightLastScanLineIndex = 0;
            int nextScanAfterLine2 = 0;
            for (int i = 0; i < scanValues.length; i++)
                if (scanValues[i] > lightLastScanLine) {
                    nextScanAfterLine2 = (int) scanValues[i];
                    break;
                }
            if (nextScanAfterLine2 == 0)
                lightLastScanLineIndex = 0;
            else {
                for (int i = 0; i < scanValuesPadded.length; i++) {
                    if (scanValuesPadded[i] >= nextScanAfterLine2) {
                        lightLastScanLineIndex = i;
                        break;
                    }
                }
            }
        }
        if (heavyFirstScanLine > 0) {
            heavyFirstScanLineIndex = 0;
            for (int i = 0; i < scanValuesPadded.length; i++) {
                if (scanValuesPadded[i] < heavyFirstScanLine) {
                    heavyFirstScanLineIndex = i;
                } else
                    break;
            }
        }
        if (heavyLastScanLine > 0) {
            heavyLastScanLineIndex = 0;
            int nextScanAfterLine2 = 0;
            for (int i = 0; i < scanValues.length; i++)
                if (scanValues[i] > heavyLastScanLine) {
                    nextScanAfterLine2 = (int) scanValues[i];
                    break;
                }
            if (nextScanAfterLine2 == 0)
                heavyLastScanLineIndex = 0;
            else {
                for (int i = 0; i < scanValuesPadded.length; i++) {
                    if (scanValuesPadded[i] >= nextScanAfterLine2) {
                        heavyLastScanLineIndex = i;
                        break;
                    }
                }
            }
        }
    }

    int lightMzIndex = 0;
    for (lightMzIndex = 0; lightMzIndex < intensityValuesPadded[0].length; lightMzIndex++)
        if (mzValues[lightMzIndex] > lightMz)
            break;
    int heavyMzIndex = 0;
    for (heavyMzIndex = 0; heavyMzIndex < intensityValuesPadded[0].length; heavyMzIndex++)
        if (mzValues[heavyMzIndex] > heavyMz)
            break;

    if (lightFirstScanLineIndex > 0)
        shadeArea(intensityValuesPadded, 0, 0, lightFirstScanLineIndex, lightMzIndex);

    if (lightLastScanLineIndex > 0)
        shadeArea(intensityValuesPadded, lightLastScanLineIndex, 0, intensityValuesPadded.length - 1,
                lightMzIndex);

    if (heavyFirstScanLineIndex > 0)
        shadeArea(intensityValuesPadded, 0, heavyMzIndex, heavyFirstScanLineIndex,
                intensityValuesPadded[0].length - 1);

    if (lightLastScanLineIndex > 0)
        shadeArea(intensityValuesPadded, heavyLastScanLineIndex, heavyMzIndex, intensityValuesPadded.length - 1,
                intensityValuesPadded[0].length - 1);

    //if light and heavy first scan are same, shade the remaining area on the left.  Same with last scan
    if (lightFirstScanLineIndex > 0 && heavyFirstScanLineIndex == lightFirstScanLineIndex)
        shadeArea(intensityValuesPadded, 0, lightMzIndex + 1, lightFirstScanLineIndex, heavyMzIndex - 1);
    if (lightLastScanLineIndex > 0 && heavyLastScanLineIndex == lightLastScanLineIndex)
        shadeArea(intensityValuesPadded, lightLastScanLineIndex, lightMzIndex + 1,
                intensityValuesPadded.length - 1, heavyMzIndex - 1);

    //special value for tick intensity
    float intensityForTickMark = -2f;
    float intensityForIdCross = -2f;

    //cross for ID event
    if (idEventScan > 0 && idEventMz > 0) {
        drawHeatmapCrossForEvent(scanValuesPadded, mzValues, intensityValuesPadded, idEventScan, idEventMz,
                intensityForIdCross);
    }

    if (otherEventScans != null && !otherEventScans.isEmpty()) {
        for (int i = 0; i < otherEventScans.size(); i++)
            drawHeatmapCrossForEvent(scanValuesPadded, mzValues, intensityValuesPadded, otherEventScans.get(i),
                    otherEventMZs.get(i), intensityForIdCross);
    }

    //tick marks for specified m/z's
    if (lightMz > 0) {
        placeHeatmapTick(mzValues, intensityValuesPadded, lightMz, intensityForTickMark);
    }
    if (heavyMz > 0) {
        placeHeatmapTick(mzValues, intensityValuesPadded, heavyMz, intensityForTickMark);
    }

    if (peakMzs != null) {
        for (float mz : nonMonoisotopicPeakMzs)
            placeHeatmapTick(mzValues, intensityValuesPadded, mz, intensityForTickMark);
    }

    if (shouldGenerate3DChart)
        generate3DPlot(scanValuesPadded, mzValues, intensityValuesPadded);

    _log.debug("Done loading spectrum in range.");

    setData(scanValuesPadded, mzValues, intensityValuesPadded);
    getChart().removeLegend();
    //try {contourPlot.saveAllImagesToFiles(new File("/home/dhmay/temp/charts"));} catch(IOException e) {}
    ((XYPlot) _plot).getDomainAxis().setRange(minScan, maxScan);
    ((XYPlot) _plot).getRangeAxis().setRange(minMz, maxMz);
}

From source file:edu.harvard.i2b2.query.QueryConceptTreePanel.java

public void redraw(QueryConceptTreeData data) {
    panelData = data;/*from   ww w  .j  av  a2 s .c  o  m*/

    String str = "Occurs > " + (data.getOccurrenceTimes() - 1) + "x";
    if (data.getOccurrenceTimes() == 1) {
        setOccurrenceText(str);
    } else if (data.getOccurrenceTimes() > 1) {
        setOccurrenceText("<html><u>" + str + "</u>");
    }

    if (data.exclude()) {
        jExcludeButton.setText("<html><center><u>Exclude</u>");
        jTree1.setBackground(Color.LIGHT_GRAY);
        jExcludeButton.setToolTipText("Include all items in panel");
    } else {
        jExcludeButton.setText("Exclude");
        jTree1.setBackground(Color.WHITE);
        jExcludeButton.setToolTipText("Exclude all items in panel");
    }

    if (data.startDay() != -1 || data.endDay() != -1) {
        setDateConstrainText("<html><u>Dates</u>");
    } else {
        setDateConstrainText("Dates");
    }

    for (int i = 0; i < data.getItems().size(); i++) {
        QueryConceptTreeNodeData node = data.getItems().get(i);
        addNode(node);
    }
}

From source file:us.paulevans.basicxslt.TransformOutputPropertiesFrame.java

/**
 * Builds the method panel//from  w w w .  jav  a2s.  co m
 * @return
 */
private JPanel buildMethodPanel() {

    int row;
    ButtonGroup group;
    GridBagLayout layout;
    GridBagConstraints constraints;
    JPanel panel;

    row = 0;
    group = new ButtonGroup();
    layout = new GridBagLayout();
    constraints = new GridBagConstraints();
    panel = new JPanel(layout);
    GUIUtils.add(panel,
            xml = new JRadioButton(
                    stringFactory.getString(LabelStringFactory.OUTPUTPROPS_FRAME_METHODS_XML) + " | "),
            layout, constraints, row, 0, 1, 1, GridBagConstraints.WEST, GridBagConstraints.NONE,
            GUIUtils.NO_INSETS);
    GUIUtils.add(panel,
            html = new JRadioButton(
                    stringFactory.getString(LabelStringFactory.OUTPUTPROPS_FRAME_METHODS_HTML) + " | "),
            layout, constraints, row, 1, 1, 1, GridBagConstraints.WEST, GridBagConstraints.NONE,
            GUIUtils.NO_INSETS);
    GUIUtils.add(panel,
            text = new JRadioButton(
                    stringFactory.getString(LabelStringFactory.OUTPUTPROPS_FRAME_METHODS_TEXT) + " | "),
            layout, constraints, row, 2, 1, 1, GridBagConstraints.WEST, GridBagConstraints.NONE,
            GUIUtils.NO_INSETS);
    GUIUtils.add(panel,
            other = new JRadioButton(
                    stringFactory.getString(LabelStringFactory.OUTPUTPROPS_FRAME_METHODS_OTHER)),
            layout, constraints, row, 3, 1, 1, GridBagConstraints.WEST, GridBagConstraints.NONE,
            GUIUtils.NO_INSETS);
    GUIUtils.add(panel, otherMethod = new JTextField(10), layout, constraints, row, 4, 1, 1,
            GridBagConstraints.WEST, GridBagConstraints.NONE, GUIUtils.NO_INSETS);
    group.add(xml);
    group.add(html);
    group.add(text);
    group.add(other);
    xml.addActionListener(this);
    html.addActionListener(this);
    text.addActionListener(this);
    other.addActionListener(this);
    xml.setSelected(true);
    otherMethod.setEnabled(false);
    otherMethod.setBackground(Color.LIGHT_GRAY);
    return panel;
}