List of usage examples for java.awt.event AdjustmentEvent getValueIsAdjusting
public boolean getValueIsAdjusting()
From source file:Main.java
private static void dumpInfo(AdjustmentEvent e) { System.out.println("getValueIsAdjusting: " + e.getValueIsAdjusting()); }
From source file:Main.java
public void adjustmentValueChanged(AdjustmentEvent evt) { Adjustable source = evt.getAdjustable(); if (evt.getValueIsAdjusting()) { return;/*from w w w . j a v a2 s. co m*/ } int orient = source.getOrientation(); if (orient == Adjustable.HORIZONTAL) { System.out.println("from horizontal scrollbar"); } else { System.out.println("from vertical scrollbar"); } int type = evt.getAdjustmentType(); switch (type) { case AdjustmentEvent.UNIT_INCREMENT: System.out.println("Scrollbar was increased by one unit"); break; case AdjustmentEvent.UNIT_DECREMENT: System.out.println("Scrollbar was decreased by one unit"); break; case AdjustmentEvent.BLOCK_INCREMENT: System.out.println("Scrollbar was increased by one block"); break; case AdjustmentEvent.BLOCK_DECREMENT: System.out.println("Scrollbar was decreased by one block"); break; case AdjustmentEvent.TRACK: System.out.println("The knob on the scrollbar was dragged"); break; } int value = evt.getValue(); }
From source file:brainleg.app.intellij.ui.EForm.java
private void configureHtmlPane() { if (htmlPane == null) { htmlPane = new JEditorPane(); htmlPane.setEditable(false);/* w w w. j av a 2 s. c o m*/ HTMLEditorKit kit = new HTMLEditorKit(); htmlPane.setEditorKit(kit); JScrollPane scrollPane = new JBScrollPane(htmlPane); scrollPane.getVerticalScrollBar().addAdjustmentListener(new AdjustmentListener() { public void adjustmentValueChanged(AdjustmentEvent e) { Adjustable source = e.getAdjustable(); // check if user is currently dragging the scrollbar's knob if (e.getValueIsAdjusting()) { return; } int orient = source.getOrientation(); if (orient == Adjustable.HORIZONTAL) { return; //we are not interested in horizontal scroll } // get the type of adjustment which caused the value changed event int type = e.getAdjustmentType(); switch (type) { case AdjustmentEvent.UNIT_INCREMENT: // System.out.println("increased by one unit"); break; case AdjustmentEvent.UNIT_DECREMENT: // System.out.println("decreased by one unit"); break; case AdjustmentEvent.BLOCK_INCREMENT: // System.out.println("increased by one block"); break; case AdjustmentEvent.BLOCK_DECREMENT: // System.out.println("decreased by one block"); break; case AdjustmentEvent.TRACK: // System.out.println("knob on the scrollbar was dragged"); break; } // get the current value in the adjustment event int value = e.getValue(); // System.out.println("Current Value: " + value); if (value > 200) { //this is about click middle mouse flip - i.e. about 15% of vertical space (approx) markExceptionAsDontShowNotificationFor(); } } }); StyleSheet styleSheet = kit.getStyleSheet(); CssUtil.addStyles(styleSheet); configureNewHtmlDocument(); htmlPane.addHyperlinkListener(new HyperlinkListener() { public void hyperlinkUpdate(HyperlinkEvent e) { if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) { try { URL url = e.getURL(); if (url != null) { BrowserUtil.launchBrowser(url.toString()); } } catch (Throwable t) { t.printStackTrace(); } } } }); solutionPanel.add(scrollPane); } }
From source file:de.codesourcery.jasm16.utils.ASTInspector.java
private void setupUI() throws MalformedURLException { // editor pane editorPane = new JTextPane(); editorScrollPane = new JScrollPane(editorPane); editorPane.addCaretListener(listener); editorScrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); editorScrollPane.setPreferredSize(new Dimension(400, 600)); editorScrollPane.setMinimumSize(new Dimension(100, 100)); final AdjustmentListener adjustmentListener = new AdjustmentListener() { @Override/* w w w . j ava2 s . c o m*/ public void adjustmentValueChanged(AdjustmentEvent e) { if (!e.getValueIsAdjusting()) { if (currentUnit != null) { doSemanticHighlighting(currentUnit); } } } }; editorScrollPane.getVerticalScrollBar().addAdjustmentListener(adjustmentListener); editorScrollPane.getHorizontalScrollBar().addAdjustmentListener(adjustmentListener); // button panel final JPanel topPanel = new JPanel(); final JToolBar toolbar = new JToolBar(); final JButton showASTButton = new JButton("Show AST"); showASTButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { boolean currentlyVisible = astInspector != null ? astInspector.isVisible() : false; if (currentlyVisible) { showASTButton.setText("Show AST"); } else { showASTButton.setText("Hide AST"); } if (currentlyVisible) { astInspector.setVisible(false); } else { showASTInspector(); } } }); fileChooser.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { final JFileChooser chooser; if (lastOpenDirectory != null && lastOpenDirectory.isDirectory()) { chooser = new JFileChooser(lastOpenDirectory); } else { lastOpenDirectory = null; chooser = new JFileChooser(); } final FileFilter filter = new FileFilter() { @Override public boolean accept(File f) { if (f.isDirectory()) { return true; } return f.isFile() && (f.getName().endsWith(".asm") || f.getName().endsWith(".dasm") || f.getName().endsWith(".dasm16")); } @Override public String getDescription() { return "DCPU-16 assembler sources"; } }; chooser.setFileFilter(filter); int returnVal = chooser.showOpenDialog(frame); if (returnVal == JFileChooser.APPROVE_OPTION) { File newFile = chooser.getSelectedFile(); if (newFile.isFile()) { lastOpenDirectory = newFile.getParentFile(); try { openFile(newFile); } catch (IOException e1) { statusModel.addError("Failed to read from file " + newFile.getAbsolutePath(), e1); } } } } }); toolbar.add(fileChooser); toolbar.add(showASTButton); final ComboBoxModel<String> model = new ComboBoxModel<String>() { private ICompilerPhase selected; private final List<String> realModel = new ArrayList<String>(); { for (ICompilerPhase p : compiler.getCompilerPhases()) { realModel.add(p.getName()); if (p.getName().equals(ICompilerPhase.PHASE_GENERATE_CODE)) { selected = p; } } } @Override public Object getSelectedItem() { return selected != null ? selected.getName() : null; } private ICompilerPhase getPhaseByName(String name) { for (ICompilerPhase p : compiler.getCompilerPhases()) { if (p.getName().equals(name)) { return p; } } return null; } @Override public void setSelectedItem(Object name) { selected = getPhaseByName((String) name); } @Override public void addListDataListener(ListDataListener l) { } @Override public String getElementAt(int index) { return realModel.get(index); } @Override public int getSize() { return realModel.size(); } @Override public void removeListDataListener(ListDataListener l) { } }; comboBox.setModel(model); comboBox.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (model.getSelectedItem() != null) { ICompilerPhase oldPhase = findDisabledPhase(); if (oldPhase != null) { oldPhase.setStopAfterExecution(false); } compiler.getCompilerPhaseByName((String) model.getSelectedItem()).setStopAfterExecution(true); try { compile(); } catch (IOException e1) { e1.printStackTrace(); } } } private ICompilerPhase findDisabledPhase() { for (ICompilerPhase p : compiler.getCompilerPhases()) { if (p.isStopAfterExecution()) { return p; } } return null; } }); toolbar.add(new JLabel("Stop compilation after: ")); toolbar.add(comboBox); cursorPosition.setSize(new Dimension(400, 15)); cursorPosition.setEditable(false); statusArea.setPreferredSize(new Dimension(400, 100)); statusArea.setModel(statusModel); /** * TOOLBAR * SOURCE * cursor position * status area */ topPanel.setLayout(new GridBagLayout()); GridBagConstraints cnstrs = constraints(0, 0, GridBagConstraints.HORIZONTAL); cnstrs.gridwidth = GridBagConstraints.REMAINDER; cnstrs.weighty = 0; topPanel.add(toolbar, cnstrs); cnstrs = constraints(0, 1, GridBagConstraints.BOTH); cnstrs.gridwidth = GridBagConstraints.REMAINDER; topPanel.add(editorScrollPane, cnstrs); cnstrs = constraints(0, 2, GridBagConstraints.HORIZONTAL); cnstrs.gridwidth = GridBagConstraints.REMAINDER; cnstrs.weighty = 0; topPanel.add(cursorPosition, cnstrs); cnstrs = constraints(0, 3, GridBagConstraints.HORIZONTAL); cnstrs.gridwidth = GridBagConstraints.REMAINDER; cnstrs.weighty = 0; final JPanel bottomPanel = new JPanel(); bottomPanel.setLayout(new GridBagLayout()); statusArea.setAutoResizeMode(JTable.AUTO_RESIZE_SUBSEQUENT_COLUMNS); statusArea.addMouseListener(new MouseAdapter() { public void mouseClicked(java.awt.event.MouseEvent e) { if (e.getButton() == MouseEvent.BUTTON1) { final int row = statusArea.rowAtPoint(e.getPoint()); StatusMessage message = statusModel.getMessage(row); if (message.getLocation() != null) { moveCursorTo(message.getLocation()); } } }; }); statusArea.setFillsViewportHeight(true); statusArea.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); final JScrollPane statusPane = new JScrollPane(statusArea); statusPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); statusPane.setPreferredSize(new Dimension(400, 100)); statusPane.setMinimumSize(new Dimension(100, 20)); cnstrs = constraints(0, 0, GridBagConstraints.BOTH); cnstrs.weightx = 1; cnstrs.weighty = 1; cnstrs.gridwidth = GridBagConstraints.REMAINDER; cnstrs.gridheight = GridBagConstraints.REMAINDER; bottomPanel.add(statusPane, cnstrs); // setup frame frame = new JFrame( "DCPU-16 assembler " + Compiler.VERSION + " (c) 2012 by tobias.gierke@code-sourcery.de"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); final JSplitPane splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, topPanel, bottomPanel); splitPane.setBackground(Color.WHITE); frame.getContentPane().add(splitPane); frame.pack(); frame.setVisible(true); splitPane.setDividerLocation(0.9); }
From source file:org.fhcrc.cpl.viewer.gui.MRMDialog.java
private void transitionListInitializations() { listTransition = new JList(); listTransition.setCellRenderer(new coloredMRMListRenderer()); listTransition.setModel(new DefaultListModel()); listTransition.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); _tlsl = new transitionListSelectionListener(); listTransition.addListSelectionListener(_tlsl); listTransition.addMouseWheelListener(new MouseWheelListener() { public void mouseWheelMoved(MouseWheelEvent event) { int move = event.getWheelRotation(); int curIndex = listTransition.getSelectedIndex(); int newIndex = curIndex; if (move > 0) { newIndex = Math.min(curIndex + move, listTransition.getModel().getSize()); listTransition.setSelectedIndex(newIndex); }/* www . j a v a 2s .c om*/ if (move < 0) { newIndex = Math.max(curIndex + move, 0); listTransition.setSelectedIndex(newIndex); } listTransition.ensureIndexIsVisible(newIndex); } }); for (MRMTransition curTran : _mrmTransitions) ((DefaultListModel) listTransition.getModel()).addElement(curTran); listTransition.setVisible(true); listScrollPane.getViewport().setView(listTransition); listScrollPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS); listScrollPane.getVerticalScrollBar().addAdjustmentListener(new AdjustmentListener() { public void adjustmentValueChanged(AdjustmentEvent ae) { if (!ae.getValueIsAdjusting()) { listTransition.repaint(); } } }); }
From source file:org.fhcrc.cpl.viewer.gui.MRMDialog.java
private void peaksDataInitializations() { String classElements[] = _ecurveclass.getName().split("\\."); elutionTableLabel.setText("<html><body><center>Elution Data<br><font size='-1'>(" + classElements[classElements.length - 1] + ")</font></center></body></html>"); elutionTableLabel.setHorizontalAlignment(JLabel.CENTER); elutionTableLabel.setHorizontalTextPosition(JLabel.CENTER); if (transDefHeader == null || transDefHeader.getAQUApairs() == null || transDefHeader.getAQUApairs().size() == 0) { buttonFindMate.setVisible(false); } else {/*w ww. j a va 2 s .com*/ buttonFindMate.setVisible(true); } peaksScrollPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS); peaksScrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS); peaksTable = new JTable(new PeaksTableModel()); //peaksTable.setPreferredScrollableViewportSize(new Dimension(500, 700)); peaksTable.setSelectionModel(new peaksTableSelectionModel()); peaksTable.setAutoscrolls(true); peaksTable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); int totalTableRows = 1; for (MRMTransition curTrans : _mrmTransitions) totalTableRows += (1 + curTrans.getDaughters().size()); ((PeaksTableModel) (peaksTable.getModel())).data = new Object[totalTableRows - 1][peaksData.values().length]; for (peaksData pd : EnumSet.allOf(peaksData.class)) { peaksTable.getColumnModel().getColumn(pd.colno).setPreferredWidth(pd.colWidth); } peaksTable.doLayout(); ((DefaultCellEditor) peaksTable.getDefaultEditor(peaksData.Accept.colClass)).setClickCountToStart(1); int i = 0; for (MRMTransition curTrans : _mrmTransitions) { curTrans.setGraphData(makeParentSeries(curTrans)); int curPrecursorIndex = i; curTrans.setTableRow(curPrecursorIndex); for (peaksData pd : EnumSet.allOf(peaksData.class)) { ((PeaksTableModel) (peaksTable.getModel())).data[i][pd.colno] = null; pd.makeVisible(true); } ((PeaksTableModel) (peaksTable.getModel())).data[i][peaksData.Accept.colno] = null; ((PeaksTableModel) (peaksTable.getModel())).data[i][peaksData.Precursor.colno] = curTrans; for (MRMDaughter d : curTrans.getDaughters().values()) { i++; d.setGraphData(d.makeDaughterSeries()); d.setContinDaughterData(d.makeDaughterSeries(d, true)); d.setElutionDataTableRow(i); ElutionCurveStrategy bes = ElutionCurveStrategy.getInstance(curTrans, d, _ecurveclass); bes.calculateParentElutionCurves(null); bes.calculateDaughterElutionCurves(null); bes.calculateBestCurves(); d.calculateQuality(); curTrans.getElutionCurves().put(d, bes); ((PeaksTableModel) (peaksTable.getModel())).data[i][peaksData.Accept.colno] = new Boolean( !Utils.allYsAre0(d)); ((PeaksTableModel) (peaksTable.getModel())).data[i][peaksData.Peptide.colno] = ""; ((PeaksTableModel) (peaksTable.getModel())).data[i][peaksData.Precursor.colno] = curTrans; ((PeaksTableModel) (peaksTable.getModel())).data[i][peaksData.Daughter.colno] = d; ((PeaksTableModel) (peaksTable.getModel())).data[i][peaksData.CoStart.colno] = null; ((PeaksTableModel) (peaksTable.getModel())).data[i][peaksData.CoEnd.colno] = null; ((PeaksTableModel) (peaksTable.getModel())).data[i][peaksData.CoDelta.colno] = null; ((PeaksTableModel) (peaksTable.getModel())).data[i][peaksData.AUC.colno] = null; ((PeaksTableModel) (peaksTable.getModel())).data[i][peaksData.MaxPeak.colno] = null; ((PeaksTableModel) (peaksTable.getModel())).data[i][peaksData.MidTime.colno] = null; ((PeaksTableModel) (peaksTable.getModel())).data[i][peaksData.Quality.colno] = null; ((PeaksTableModel) (peaksTable.getModel())).data[i][peaksData.Label.colno] = ""; ((PeaksTableModel) (peaksTable.getModel())).data[i][peaksData.Code.colno] = null; ((PeaksTableModel) (peaksTable.getModel())).data[i][peaksData.LHRatio.colno] = null; ((PeaksTableModel) (peaksTable.getModel())).data[i][peaksData.Comment.colno] = ""; if (transDefHeader != null && transDefHeader.getDToTD() != null && transDefHeader.getDToTD().get(d) != null) { TransitionDefinition td = transDefHeader.getDToTD().get(d); ((PeaksTableModel) (peaksTable.getModel())).data[i][peaksData.Peptide.colno] = td.getPeptide(); ((PeaksTableModel) (peaksTable .getModel())).data[curPrecursorIndex][peaksData.Peptide.colno] = td.getPeptide(); ((PeaksTableModel) (peaksTable.getModel())).data[i][peaksData.Code.colno] = new Integer( td.getAQUAcode()); } ElutionCurve bestPrecursorCurve = bes.getBestParentCurve(); if (bestPrecursorCurve == null || bestPrecursorCurve.getMinElutionTimeSecs() <= 0.0) { ((PeaksTableModel) (peaksTable .getModel())).data[curPrecursorIndex][peaksData.AUC.colno] = new Float(-1); ((PeaksTableModel) (peaksTable .getModel())).data[curPrecursorIndex][peaksData.MaxPeak.colno] = new Float(-1); ((PeaksTableModel) (peaksTable .getModel())).data[curPrecursorIndex][peaksData.Quality.colno] = new Float(-1); ((PeaksTableModel) (peaksTable .getModel())).data[curPrecursorIndex][peaksData.MidTime.colno] = new Float(-1); } else { ((PeaksTableModel) (peaksTable .getModel())).data[curPrecursorIndex][peaksData.AUC.colno] = new Float( bestPrecursorCurve.getAUC()); ((PeaksTableModel) (peaksTable .getModel())).data[curPrecursorIndex][peaksData.MaxPeak.colno] = new Float( bestPrecursorCurve.getHighestPointY()); ((PeaksTableModel) (peaksTable .getModel())).data[curPrecursorIndex][peaksData.Quality.colno] = new Float( curTrans.getQuality()); } ElutionCurve bestDaughterCurve = bes.getBestDaughterCurve(); if (bestDaughterCurve == null || bestDaughterCurve.getMinElutionTimeSecs() <= 0.0) { ((PeaksTableModel) (peaksTable.getModel())).data[i][peaksData.Accept.colno] = new Boolean( false); ((PeaksTableModel) (peaksTable.getModel())).data[i][peaksData.AUC.colno] = new Float(-1); ((PeaksTableModel) (peaksTable.getModel())).data[i][peaksData.MaxPeak.colno] = new Float(-1); ((PeaksTableModel) (peaksTable.getModel())).data[i][peaksData.Quality.colno] = new Float(-1); ((PeaksTableModel) (peaksTable.getModel())).data[i][peaksData.MidTime.colno] = new Float(-1); } else { ((PeaksTableModel) (peaksTable.getModel())).data[i][peaksData.AUC.colno] = new Float( bestDaughterCurve.getAUC()); ((PeaksTableModel) (peaksTable.getModel())).data[i][peaksData.MaxPeak.colno] = new Float( bestDaughterCurve.getHighestPointY()); d.setBestElutionCurve(bestDaughterCurve); ((PeaksTableModel) (peaksTable.getModel())).data[i][peaksData.Quality.colno] = new Float( d.getQuality()); if (_minPeakCutoff > 0 && bestDaughterCurve.getHighestPointY() < _minPeakCutoff) ((PeaksTableModel) (peaksTable.getModel())).data[i][peaksData.Accept.colno] = new Boolean( false); if (_minAreaCutoff > 0 && bestDaughterCurve.getAUC() < _minAreaCutoff) ((PeaksTableModel) (peaksTable.getModel())).data[i][peaksData.Accept.colno] = new Boolean( false); } } curTrans.setElutionRegionStart(curTrans.calculateMinOfAllBestDaughterCurves()); curTrans.setElutionRegionEnd(curTrans.calculateMaxOfAllBestDaughterCurves()); curTrans.calcMaxYofAllDaughters(); for (int j = curPrecursorIndex; j <= i; j++) { ((PeaksTableModel) (peaksTable.getModel())).data[j][peaksData.CoStart.colno] = new Float( curTrans.getElutionRegionStart()); ((PeaksTableModel) (peaksTable.getModel())).data[j][peaksData.CoEnd.colno] = new Float( curTrans.getElutionRegionEnd()); ((PeaksTableModel) (peaksTable.getModel())).data[j][peaksData.CoDelta.colno] = new Float( curTrans.getElutionRegionEnd() - curTrans.getElutionRegionStart()); ((PeaksTableModel) (peaksTable.getModel())).data[j][peaksData.MidTime.colno] = new Float( curTrans.getCalcXatMaxYAllDaughters()); } i++; } peaksTable.setDefaultRenderer(MRMTransition.class, new MRMTransitionTableRenderer(false)); peaksTable.setDefaultRenderer(MRMDaughter.class, new MRMDaughterTableRenderer(false)); peaksTable.setDefaultRenderer(Number.class, new MRMNumberTableRenderer()); peaksTable.setDefaultRenderer(Integer.class, new MRMNumberTableRenderer()); peaksTable.setDefaultRenderer(Boolean.class, new MRMBooleanRenderer()); peaksTable.getColumnModel().getColumn(peaksData.CoStart.colno).setCellEditor(new NumberTableCellEditor()); peaksTable.getColumnModel().getColumn(peaksData.CoEnd.colno).setCellEditor(new NumberTableCellEditor()); peaksTable.getColumnModel().getColumn(peaksData.Code.colno).setCellEditor(new NumberTableCellEditor()); peaksTable.getColumnModel().getColumn(peaksData.LHRatio.colno).setCellEditor(new NumberTableCellEditor()); peaksScrollPane.getViewport().setView(peaksTable); if (transDefHeader == null) { peaksData.Peptide.makeVisible(false); peaksData.Label.makeVisible(false); peaksData.LHRatio.makeVisible(false); peaksData.Code.makeVisible(false); } else { if (transDefHeader.getAQUApairs() == null || transDefHeader.getAQUApairs().isEmpty()) { peaksData.Label.makeVisible(false); peaksData.LHRatio.makeVisible(false); peaksData.Code.makeVisible(false); } } // "Quality" column, currently unused, is invisible unless one or more of its // values is not -1 peaksData.Quality.makeVisible(!Utils.qualColIsEmpty()); peaksScrollPane.getVerticalScrollBar().addAdjustmentListener(new AdjustmentListener() { public void adjustmentValueChanged(AdjustmentEvent ae) { if (!ae.getValueIsAdjusting()) { peaksTable.repaint(); } } }); peaksTable.getModel().addTableModelListener(new peaksTableListener()); _ptmlsl = new PeaksTableListSelectionListener(); peaksTable.getSelectionModel().addListSelectionListener(_ptmlsl); }