List of usage examples for java.awt Cursor getPredefinedCursor
public static Cursor getPredefinedCursor(int type)
From source file:org.gumtree.vis.plot1d.Plot1DPanel.java
@Override public void mouseMoved(MouseEvent e) { Insets insets = getInsets();/* w w w . ja v a 2s . c o m*/ int x = (int) ((e.getX() - insets.left) / getScaleX()); int y = (int) ((e.getY() - insets.top) / getScaleY()); ChartEntity entity = null; if (getChartRenderingInfo() != null) { EntityCollection entities = getChartRenderingInfo().getEntityCollection(); if (entities != null) { entity = entities.getEntity(x, y); // boolean isDirty = false; int seriesIndex = -1; if (selectedSeriesIndex >= 0) { // double xInChart = ChartMaskingUtilities.translateScreenX(x, // getScreenDataArea(), getChart()); // XYDataset dataset = getChart().getXYPlot().getDataset(); // PatternDataset patternDataset = (PatternDataset) dataset; // int itemIndex = patternDataset.getItemFromX(selectedSeriesIndex, xInChart); // if (itemIndex < patternDataset.getItemCount(selectedSeriesIndex)) { // chartX = patternDataset.getXValue(selectedSeriesIndex, itemIndex); // chartY = patternDataset.getYValue(selectedSeriesIndex, itemIndex); // Point2D axisTrace = ChartMaskingUtilities.translateChartPoint( // new Point2D.Double(chartX, chartY), getScreenDataArea(), getChart()); // horizontalTraceLocation = (int) axisTrace.getX(); // verticalTraceLocation = (int) axisTrace.getY(); // if (getHorizontalAxisTrace() || getVerticalAxisTrace() || isToolTipFollowerEnabled) { // repaint(); // } // seriesIndex = selectedSeriesIndex; // isDirty = true; // } seriesIndex = followDomainTrace(selectedSeriesIndex, x); if (seriesIndex >= 0 && (getHorizontalAxisTrace() || getVerticalAxisTrace() || isToolTipFollowerEnabled())) { repaint(); } } else if (getChart().getXYPlot().getSeriesCount() == 1) { // int seriesIndex0 = 0; // double xInChart = ChartMaskingUtilities.translateScreenX(x, // getScreenDataArea(), getChart()); // XYDataset dataset = getChart().getXYPlot().getDataset(); // PatternDataset patternDataset = (PatternDataset) dataset; // int itemIndex = patternDataset.getItemFromX(seriesIndex0, xInChart); // if (itemIndex < patternDataset.getItemCount(seriesIndex0)) { // chartX = patternDataset.getXValue(seriesIndex0, itemIndex); // chartY = patternDataset.getYValue(seriesIndex0, itemIndex); // Point2D axisTrace = ChartMaskingUtilities.translateChartPoint( // new Point2D.Double(chartX, chartY), getScreenDataArea(), getChart()); //// if (getScreenDataArea().contains(axisTrace)) { // horizontalTraceLocation = (int) axisTrace.getX(); // verticalTraceLocation = (int) axisTrace.getY(); // if (getHorizontalAxisTrace() || getVerticalAxisTrace() || isToolTipFollowerEnabled) { // repaint(); // } // seriesIndex = seriesIndex0; // isDirty = true; //// } // } seriesIndex = followDomainTrace(0, x); if (seriesIndex >= 0 && (getHorizontalAxisTrace() || getVerticalAxisTrace() || isToolTipFollowerEnabled())) { repaint(); } } else if (entity instanceof XYItemEntity) { XYItemEntity xyEntity = (XYItemEntity) entity; XYDataset dataset = xyEntity.getDataset(); int item = ((XYItemEntity) entity).getItem(); seriesIndex = xyEntity.getSeriesIndex(); double chartX = dataset.getXValue(seriesIndex, item); double chartY = dataset.getYValue(seriesIndex, item); Point2D screenPoint = ChartMaskingUtilities.translateChartPoint( new Point2D.Double(chartX, chartY), getScreenDataArea(), getChart()); setChartX(chartX); setChartY(chartY); setSeriesIndex(seriesIndex); setItemIndex(item); if (dataset instanceof IXYErrorDataset) { setChartError(((IXYErrorDataset) dataset).getYError(seriesIndex, item)); } if (getHorizontalAxisTrace()) { setHorizontalTraceLocation((int) screenPoint.getX()); } if (getVerticalAxisTrace()) { setVerticalTraceLocation((int) screenPoint.getY()); } if (getHorizontalAxisTrace() || getVerticalAxisTrace() || isToolTipFollowerEnabled()) { repaint(); } // isDirty = true; } if (seriesIndex >= 0) { Object[] listeners = getListeners(ChartMouseListener.class); if (getChart() != null) { XYChartMouseEvent event = new XYChartMouseEvent(getChart(), e, entity); event.setXY(getChartX(), getChartY()); event.setSeriesIndex(seriesIndex); for (int i = listeners.length - 1; i >= 0; i -= 1) { ((ChartMouseListener) listeners[i]).chartMouseMoved(event); } } } } // getChart().handleClick(x, y, getChartRenderingInfo()); } if (isInternalLegendEnabled && isInternalLegendSelected) { int cursorType = findCursorOnSelectedItem(e.getX(), e.getY()); setCursor(Cursor.getPredefinedCursor(cursorType)); } else if (getCursor() != defaultCursor) { setCursor(defaultCursor); } super.mouseMoved(e); // we can only generate events if the panel's chart is not null // (see bug report 1556951) }
From source file:de.bfs.radon.omsimulation.gui.OMPanelResults.java
/** * Initialises the interface of the results panel. *///from ww w . j a v a2 s.c o m protected void initialize() { setLayout(null); lblExportChartTo = new JLabel("Export chart to ..."); lblExportChartTo.setBounds(436, 479, 144, 14); lblExportChartTo.setFont(new Font(Font.SANS_SERIF, Font.PLAIN, 11)); lblExportChartTo.setVisible(false); add(lblExportChartTo); btnMaximize = new JButton("Fullscreen"); btnMaximize.setBounds(10, 475, 124, 23); btnMaximize.setFont(new Font("SansSerif", Font.PLAIN, 11)); btnMaximize.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { if (comboBoxSimulations.isEnabled()) { if (comboBoxSimulations.getSelectedItem() != null) { JFrame chartFrame = new JFrame(); OMSimulation simulation = (OMSimulation) comboBoxSimulations.getSelectedItem(); String title = simulation.toString(); DescriptiveStatistics statistics = null; OMStatistics statisticsType = (OMStatistics) comboBoxStatistics.getSelectedItem(); OMRoomType roomType = null; switch (statisticsType) { case RoomArithmeticMeans: title = "R_AM, " + title; statistics = simulation.getRoomAmDescriptiveStats(); roomType = OMRoomType.Room; break; case RoomGeometricMeans: title = "R_GM, " + title; statistics = simulation.getRoomGmDescriptiveStats(); roomType = OMRoomType.Room; break; case RoomMedianQ50: title = "R_MED, " + title; statistics = simulation.getRoomMedDescriptiveStats(); roomType = OMRoomType.Room; break; case RoomMaxima: title = "R_MAX, " + title; statistics = simulation.getRoomMaxDescriptiveStats(); roomType = OMRoomType.Room; break; case CellarArithmeticMeans: title = "C_AM, " + title; statistics = simulation.getCellarAmDescriptiveStats(); roomType = OMRoomType.Cellar; break; case CellarGeometricMeans: title = "C_GM, " + title; statistics = simulation.getCellarGmDescriptiveStats(); roomType = OMRoomType.Cellar; break; case CellarMedianQ50: title = "C_MED, " + title; statistics = simulation.getCellarMedDescriptiveStats(); roomType = OMRoomType.Cellar; break; case CellarMaxima: title = "C_MAX, " + title; statistics = simulation.getCellarMaxDescriptiveStats(); roomType = OMRoomType.Cellar; break; default: title = "R_AM, " + title; statistics = simulation.getRoomAmDescriptiveStats(); roomType = OMRoomType.Misc; break; } JPanel chartPanel = createDistributionPanel(title, statistics, roomType, false, true, true); chartFrame.getContentPane().add(chartPanel); chartFrame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); Dimension dim = Toolkit.getDefaultToolkit().getScreenSize(); chartFrame.setBounds(0, 0, (int) dim.getWidth(), (int) dim.getHeight()); chartFrame.setTitle("OM Simulation Tool: " + title); chartFrame.setResizable(true); chartFrame.setExtendedState(JFrame.MAXIMIZED_BOTH); chartFrame.setVisible(true); } } } }); add(btnMaximize); btnCsv = new JButton("CSV"); btnCsv.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { JFileChooser fileDialog = new JFileChooser(); fileDialog.setFileFilter(new FileNameExtensionFilter("*.csv", "csv")); fileDialog.showSaveDialog(getParent()); final File file = fileDialog.getSelectedFile(); if (file != null) { String csv; String[] tmpFileName = file.getAbsolutePath().split("\\."); if (tmpFileName[tmpFileName.length - 1].equals("csv")) { csv = ""; } else { csv = ".csv"; } String csvPath = file.getAbsolutePath() + csv; OMSimulation simulation = (OMSimulation) comboBoxSimulations.getSelectedItem(); OMCampaign[] campaigns = simulation.getCampaigns(); File csvFile = new File(csvPath); try { FileWriter logWriter = new FileWriter(csvFile); BufferedWriter csvOutput = new BufferedWriter(logWriter); OMStatistics statisticsType = (OMStatistics) comboBoxStatistics.getSelectedItem(); String head = ""; switch (statisticsType) { case RoomArithmeticMeans: head = "R_AM"; break; case RoomGeometricMeans: head = "R_GM"; break; case RoomMedianQ50: head = "R_MED"; break; case RoomMaxima: head = "R_MAX"; break; case CellarArithmeticMeans: head = "C_AM"; break; case CellarGeometricMeans: head = "C_GM"; break; case CellarMedianQ50: head = "C_MED"; break; case CellarMaxima: head = "C_MAX"; break; default: head = "R_AM"; break; } csvOutput.write("\"ID\";\"CAMPAIGN\";\"START\";\"" + head + "\""); csvOutput.newLine(); int value = 0; for (int i = 0; i < campaigns.length; i++) { switch (statisticsType) { case RoomArithmeticMeans: value = (int) campaigns[i].getRoomAverage(); break; case RoomGeometricMeans: value = (int) campaigns[i].getRoomLogAverage(); break; case RoomMedianQ50: value = (int) campaigns[i].getRoomMedian(); break; case RoomMaxima: value = (int) campaigns[i].getRoomMaximum(); break; case CellarArithmeticMeans: value = (int) campaigns[i].getCellarAverage(); break; case CellarGeometricMeans: value = (int) campaigns[i].getCellarLogAverage(); break; case CellarMedianQ50: value = (int) campaigns[i].getCellarMedian(); break; case CellarMaxima: value = (int) campaigns[i].getCellarMaximum(); break; default: value = (int) campaigns[i].getRoomAverage(); break; } csvOutput.write("\"" + i + "\";\"" + campaigns[i].getVariation() + "\";\"" + campaigns[i].getStart() + "\";\"" + value + "\""); csvOutput.newLine(); } JOptionPane.showMessageDialog(null, "CSV saved successfully!\n" + csvPath, "Success", JOptionPane.INFORMATION_MESSAGE); csvOutput.close(); } catch (IOException ioe) { JOptionPane.showMessageDialog(null, "Failed to write CSV. Please check permissions!\n" + ioe.getMessage(), "Failed", JOptionPane.ERROR_MESSAGE); ioe.printStackTrace(); } } else { JOptionPane.showMessageDialog(null, "Failed to write CSV. Please check the file path!", "Failed", JOptionPane.ERROR_MESSAGE); } } }); btnCsv.setBounds(590, 475, 70, 23); btnCsv.setFont(new Font(Font.SANS_SERIF, Font.PLAIN, 11)); btnCsv.setVisible(false); add(btnCsv); btnPdf = new JButton("PDF"); btnPdf.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { JFileChooser fileDialog = new JFileChooser(); fileDialog.setFileFilter(new FileNameExtensionFilter("*.pdf", "pdf")); fileDialog.showSaveDialog(getParent()); final File file = fileDialog.getSelectedFile(); if (file != null) { String pdf; String[] tmpFileName = file.getAbsolutePath().split("\\."); if (tmpFileName[tmpFileName.length - 1].equals("pdf")) { pdf = ""; } else { pdf = ".pdf"; } String pdfPath = file.getAbsolutePath() + pdf; OMSimulation simulation = (OMSimulation) comboBoxSimulations.getSelectedItem(); String title = simulation.toString(); DescriptiveStatistics statistics = null; OMStatistics statisticsType = (OMStatistics) comboBoxStatistics.getSelectedItem(); OMRoomType roomType = null; switch (statisticsType) { case RoomArithmeticMeans: title = "R_AM, " + title; statistics = simulation.getRoomAmDescriptiveStats(); roomType = OMRoomType.Room; break; case RoomGeometricMeans: title = "R_GM, " + title; statistics = simulation.getRoomGmDescriptiveStats(); roomType = OMRoomType.Room; break; case RoomMedianQ50: title = "R_MED, " + title; statistics = simulation.getRoomMedDescriptiveStats(); roomType = OMRoomType.Room; break; case RoomMaxima: title = "R_MAX, " + title; statistics = simulation.getRoomMaxDescriptiveStats(); roomType = OMRoomType.Room; break; case CellarArithmeticMeans: title = "C_AM, " + title; statistics = simulation.getCellarAmDescriptiveStats(); roomType = OMRoomType.Cellar; break; case CellarGeometricMeans: title = "C_GM, " + title; statistics = simulation.getCellarGmDescriptiveStats(); roomType = OMRoomType.Cellar; break; case CellarMedianQ50: title = "C_MED, " + title; statistics = simulation.getCellarMedDescriptiveStats(); roomType = OMRoomType.Cellar; break; case CellarMaxima: title = "C_MAX, " + title; statistics = simulation.getCellarMaxDescriptiveStats(); roomType = OMRoomType.Cellar; break; default: title = "R_AM, " + title; statistics = simulation.getRoomAmDescriptiveStats(); roomType = OMRoomType.Misc; break; } JFreeChart chart = OMCharts.createDistributionChart(title, statistics, roomType, false); int height = (int) PageSize.A4.getWidth(); int width = (int) PageSize.A4.getHeight(); try { OMExports.exportPdf(pdfPath, chart, width, height, new DefaultFontMapper(), title); JOptionPane.showMessageDialog(null, "PDF saved successfully!\n" + pdfPath, "Success", JOptionPane.INFORMATION_MESSAGE); } catch (IOException ioe) { JOptionPane.showMessageDialog(null, "Failed to write PDF. Please check permissions!\n" + ioe.getMessage(), "Failed", JOptionPane.ERROR_MESSAGE); ioe.printStackTrace(); } } else { JOptionPane.showMessageDialog(null, "Failed to write PDF. Please check the file path!", "Failed", JOptionPane.ERROR_MESSAGE); } } }); btnPdf.setBounds(670, 475, 70, 23); btnPdf.setFont(new Font(Font.SANS_SERIF, Font.PLAIN, 11)); btnPdf.setVisible(false); add(btnPdf); lblSelectSimulation = new JLabel("Select Simulation"); lblSelectSimulation.setFont(new Font("SansSerif", Font.PLAIN, 11)); lblSelectSimulation.setBounds(10, 65, 132, 14); add(lblSelectSimulation); lblSelectStatistics = new JLabel("Select Statistics"); lblSelectStatistics.setFont(new Font("SansSerif", Font.PLAIN, 11)); lblSelectStatistics.setBounds(10, 94, 132, 14); add(lblSelectStatistics); comboBoxSimulations = new JComboBox<OMSimulation>(); comboBoxSimulations.setFont(new Font("SansSerif", Font.PLAIN, 11)); comboBoxSimulations.addPropertyChangeListener(new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent arg0) { boolean b = false; if (comboBoxSimulations.isEnabled()) { if (comboBoxSimulations.getSelectedItem() != null) { b = true; comboBoxStatistics.removeAllItems(); comboBoxStatistics.setModel(new DefaultComboBoxModel<OMStatistics>(OMStatistics.values())); } else { b = false; comboBoxStatistics.removeAllItems(); } } else { b = false; comboBoxStatistics.removeAllItems(); } progressBar.setEnabled(b); btnPdf.setVisible(b); btnCsv.setVisible(b); btnMaximize.setVisible(b); lblExportChartTo.setVisible(b); comboBoxStatistics.setEnabled(b); lblSelectStatistics.setEnabled(b); } }); comboBoxSimulations.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { boolean b = false; if (comboBoxSimulations.isEnabled()) { if (comboBoxSimulations.getSelectedItem() != null) { b = true; comboBoxStatistics.removeAllItems(); comboBoxStatistics.setModel(new DefaultComboBoxModel<OMStatistics>(OMStatistics.values())); comboBoxStatistics.setSelectedIndex(0); } else { b = false; comboBoxStatistics.removeAllItems(); } } else { b = false; comboBoxStatistics.removeAllItems(); } progressBar.setEnabled(b); btnPdf.setVisible(b); btnCsv.setVisible(b); btnMaximize.setVisible(b); lblExportChartTo.setVisible(b); comboBoxStatistics.setEnabled(b); lblSelectStatistics.setEnabled(b); } }); comboBoxSimulations.setBounds(152, 61, 454, 22); add(comboBoxSimulations); btnRefresh = new JButton("Load"); btnRefresh.setFont(new Font("SansSerif", Font.PLAIN, 11)); btnRefresh.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { if (txtOmsFile.getText() != null && !txtOmsFile.getText().equals("") && !txtOmsFile.getText().equals(" ")) { txtOmsFile.setBackground(Color.WHITE); String omsPath = txtOmsFile.getText(); String oms; String[] tmpFileName = omsPath.split("\\."); if (tmpFileName[tmpFileName.length - 1].equals("oms")) { oms = ""; } else { oms = ".oms"; } txtOmsFile.setText(omsPath + oms); setOmsFile(omsPath + oms); File omsFile = new File(omsPath + oms); if (omsFile.exists()) { txtOmsFile.setBackground(Color.WHITE); btnRefresh.setEnabled(false); comboBoxSimulations.setEnabled(false); setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); progressBar.setStringPainted(true); progressBar.setVisible(true); progressBar.setIndeterminate(true); btnPdf.setVisible(false); btnCsv.setVisible(false); btnMaximize.setVisible(false); lblExportChartTo.setVisible(false); refreshSimulationsTask = new RefreshSimulations(); refreshSimulationsTask.execute(); } else { txtOmsFile.setBackground(new Color(255, 222, 222, 128)); JOptionPane.showMessageDialog(null, "OMS-file not found, please check the file path!", "Error", JOptionPane.ERROR_MESSAGE); } } else { txtOmsFile.setBackground(new Color(255, 222, 222, 128)); JOptionPane.showMessageDialog(null, "Please select an OMS-file!", "Warning", JOptionPane.WARNING_MESSAGE); } } }); comboBoxStatistics = new JComboBox<OMStatistics>(); comboBoxStatistics.setFont(new Font("SansSerif", Font.PLAIN, 11)); comboBoxStatistics.setBounds(152, 90, 454, 22); comboBoxStatistics.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { updateDistribution(); } }); add(comboBoxStatistics); btnRefresh.setBounds(616, 61, 124, 23); add(btnRefresh); panelDistribution = new JPanel(); panelDistribution.setBounds(10, 118, 730, 347); add(panelDistribution); progressBar = new JProgressBar(); progressBar.setFont(new Font("SansSerif", Font.PLAIN, 11)); progressBar.setBounds(10, 475, 730, 23); add(progressBar); progressBar.setEnabled(false); comboBoxStatistics.setEnabled(false); lblSelectStatistics.setEnabled(false); btnPdf.setVisible(false); btnCsv.setVisible(false); btnMaximize.setVisible(false); lblExportChartTo.setVisible(false); lblHelp = new JLabel("Select an OMS-Simulation file to analyse the simulation results and " + "display the distribution chart."); lblHelp.setForeground(Color.GRAY); lblHelp.setFont(new Font("SansSerif", Font.PLAIN, 11)); lblHelp.setBounds(10, 10, 730, 14); add(lblHelp); lblSelectOms = new JLabel("Open OMS-File"); lblSelectOms.setFont(new Font("SansSerif", Font.PLAIN, 11)); lblSelectOms.setBounds(10, 36, 132, 14); add(lblSelectOms); txtOmsFile = new JTextField(); txtOmsFile.addFocusListener(new FocusAdapter() { @Override public void focusLost(FocusEvent e) { setOmsFile(txtOmsFile.getText()); } }); txtOmsFile.setFont(new Font("SansSerif", Font.PLAIN, 11)); txtOmsFile.setColumns(10); txtOmsFile.setBounds(152, 33, 454, 20); add(txtOmsFile); buttonBrowse = new JButton("Browse"); buttonBrowse.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { JFileChooser fileDialog = new JFileChooser(); fileDialog.setFileFilter(new FileNameExtensionFilter("*.oms", "oms")); fileDialog.showOpenDialog(getParent()); final File file = fileDialog.getSelectedFile(); if (file != null) { String oms; String[] tmpFileName = file.getAbsolutePath().split("\\."); if (tmpFileName[tmpFileName.length - 1].equals("oms")) { oms = ""; } else { oms = ".oms"; } txtOmsFile.setText(file.getAbsolutePath() + oms); setOmsFile(file.getAbsolutePath() + oms); } } }); buttonBrowse.setFont(new Font("SansSerif", Font.PLAIN, 11)); buttonBrowse.setBounds(616, 32, 124, 23); add(buttonBrowse); progressBar.setVisible(false); }
From source file:it.imtech.metadata.MetaUtility.java
/** * Metodo adibito alla creazione dinamica ricorsiva dell'interfaccia dei * metadati//from ww w. j av a 2 s .c om * * @param submetadatas Map contente i metadati e i sottolivelli di metadati * @param vocabularies Map contenente i dati contenuti nel file xml * vocabulary.xml * @param parent Jpanel nel quale devono venir inseriti i metadati * @param level Livello corrente */ public void create_metadata_view(Map<Object, Metadata> submetadatas, JPanel parent, int level, final String panelname) throws Exception { ResourceBundle bundle = ResourceBundle.getBundle(Globals.RESOURCES, Globals.CURRENT_LOCALE, Globals.loader); int lenght = submetadatas.size(); int labelwidth = 220; int i = 0; JButton addcontribute = null; for (Map.Entry<Object, Metadata> kv : submetadatas.entrySet()) { ArrayList<Component> tabobjects = new ArrayList<Component>(); if (kv.getValue().MID == 17 || kv.getValue().MID == 23 || kv.getValue().MID == 18 || kv.getValue().MID == 137) { continue; } //Crea un jpanel nuovo e fa appen su parent JPanel innerPanel = new JPanel(new MigLayout("fillx, insets 1 1 1 1")); innerPanel.setName("pannello" + level + i); i++; String datatype = kv.getValue().datatype.toString(); if (kv.getValue().MID == 45) { JPanel choice = new JPanel(new MigLayout()); JComboBox combo = addClassificationChoice(choice, kv.getValue().sequence, panelname); JLabel labelc = new JLabel(); labelc.setText(Utility.getBundleString("selectclassif", bundle)); labelc.setPreferredSize(new Dimension(100, 20)); choice.add(labelc); findLastClassification(panelname); if (last_classification != 0 && classificationRemoveButton == null) { logger.info("Removing last clasification"); classificationRemoveButton = new JButton("-"); classificationRemoveButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent event) { BookImporter.getInstance().setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); removeClassificationToMetadata(panelname); BookImporter.getInstance().refreshMetadataTab(false, panelname); findLastClassification(panelname); //update last_classification BookImporter.getInstance().setCursor(null); } }); if (Integer.parseInt(kv.getValue().sequence) == last_classification) { choice.add(classificationRemoveButton, "wrap, width :50:"); } } if (classificationAddButton == null) { logger.info("Adding a new classification"); choice.add(combo, "width 100:600:600"); classificationAddButton = new JButton("+"); classificationAddButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent event) { BookImporter.getInstance().setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); addClassificationToMetadata(panelname); BookImporter.getInstance().refreshMetadataTab(false, panelname); BookImporter.getInstance().setCursor(null); } }); choice.add(classificationAddButton, "width :50:"); } else { //choice.add(combo, "wrap,width 100:700:700"); choice.add(combo, "width 100:700:700"); if (Integer.parseInt(kv.getValue().sequence) == last_classification) { choice.add(classificationRemoveButton, "wrap, width :50"); } } parent.add(choice, "wrap,width 100:700:700"); classificationMID = kv.getValue().MID; innerPanel.setName(panelname + "---ImPannelloClassif---" + kv.getValue().sequence); try { addClassification(innerPanel, classificationMID, kv.getValue().sequence, panelname); } catch (Exception ex) { logger.error("Errore nell'aggiunta delle classificazioni"); } parent.add(innerPanel, "wrap, growx"); BookImporter.policy.addIndexedComponent(combo); continue; } if (datatype.equals("Node")) { JLabel label = new JLabel(); label.setText(kv.getValue().description); label.setPreferredSize(new Dimension(100, 20)); int size = 16 - (level * 2); Font myFont = new Font("MS Sans Serif", Font.PLAIN, size); label.setFont(myFont); if (Integer.toString(kv.getValue().MID).equals("11")) { JPanel temppanel = new JPanel(new MigLayout()); //update last_contribute findLastContribute(panelname); if (last_contribute != 0 && removeContribute == null) { logger.info("Removing last contribute"); removeContribute = new JButton("-"); removeContribute.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent event) { BookImporter.getInstance() .setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); removeContributorToMetadata(panelname); BookImporter.getInstance().refreshMetadataTab(false, panelname); BookImporter.getInstance().setCursor(null); } }); if (!kv.getValue().sequence.equals("")) { if (Integer.parseInt(kv.getValue().sequence) == last_contribute) { innerPanel.add(removeContribute, "width :50:"); } } } if (addcontribute == null) { logger.info("Adding a new contribute"); addcontribute = new JButton("+"); addcontribute.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent event) { BookImporter.getInstance() .setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); addContributorToMetadata(panelname); BookImporter.getInstance().refreshMetadataTab(false, panelname); BookImporter.getInstance().setCursor(null); } }); temppanel.add(label, " width :200:"); temppanel.add(addcontribute, "width :50:"); innerPanel.add(temppanel, "wrap, growx"); } else { temppanel.add(label, " width :200:"); findLastContribute(panelname); if (!kv.getValue().sequence.equals("")) { if (Integer.parseInt(kv.getValue().sequence) == last_contribute) { temppanel.add(removeContribute, "width :50:"); } } innerPanel.add(temppanel, "wrap, growx"); } } else if (Integer.toString(kv.getValue().MID).equals("115")) { logger.info("Devo gestire una provenience!"); } } else { String title = ""; if (kv.getValue().mandatory.equals("Y") || kv.getValue().MID == 14 || kv.getValue().MID == 15) { title = kv.getValue().description + " *"; } else { title = kv.getValue().description; } innerPanel.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), title, TitledBorder.LEFT, TitledBorder.TOP)); if (datatype.equals("Vocabulary")) { TreeMap<String, String> entryCombo = new TreeMap<String, String>(); int index = 0; String selected = null; if (!Integer.toString(kv.getValue().MID).equals("8")) entryCombo.put(Utility.getBundleString("comboselect", bundle), Utility.getBundleString("comboselect", bundle)); for (Map.Entry<String, TreeMap<String, VocEntry>> vc : vocabularies.entrySet()) { String tempmid = Integer.toString(kv.getValue().MID); if (Integer.toString(kv.getValue().MID_parent).equals("11") || Integer.toString(kv.getValue().MID_parent).equals("13")) { String[] testmid = tempmid.split("---"); tempmid = testmid[0]; } if (vc.getKey().equals(tempmid)) { TreeMap<String, VocEntry> iEntry = vc.getValue(); for (Map.Entry<String, VocEntry> ivc : iEntry.entrySet()) { entryCombo.put(ivc.getValue().description, ivc.getValue().ID); if (kv.getValue().value != null) { if (kv.getValue().value.equals(ivc.getValue().ID)) { selected = ivc.getValue().ID; } } index++; } } } final ComboMapImpl model = new ComboMapImpl(); model.setVocabularyCombo(true); model.putAll(entryCombo); final JComboBox voc = new javax.swing.JComboBox(model); model.specialRenderCombo(voc); if (Integer.toString(kv.getValue().MID_parent).equals("11") || Integer.toString(kv.getValue().MID_parent).equals("13")) { voc.setName("MID_" + Integer.toString(kv.getValue().MID) + "---" + kv.getValue().sequence); } else { voc.setName("MID_" + Integer.toString(kv.getValue().MID)); } if (Integer.toString(kv.getValue().MID).equals("8") && selected == null) selected = "44"; selected = (selected == null) ? Utility.getBundleString("comboselect", bundle) : selected; for (int k = 0; k < voc.getItemCount(); k++) { Map.Entry<String, String> el = (Map.Entry<String, String>) voc.getItemAt(k); if (el.getValue().equals(selected)) voc.setSelectedIndex(k); } voc.setPreferredSize(new Dimension(150, 30)); innerPanel.add(voc, "wrap, width :400:"); tabobjects.add(voc); } else if (datatype.equals("CharacterString") || datatype.equals("GPS")) { final JTextArea textField = new javax.swing.JTextArea(); if (Integer.toString(kv.getValue().MID_parent).equals("11") || Integer.toString(kv.getValue().MID_parent).equals("13")) { textField.setName( "MID_" + Integer.toString(kv.getValue().MID) + "---" + kv.getValue().sequence); } else { textField.setName("MID_" + Integer.toString(kv.getValue().MID)); } textField.setPreferredSize(new Dimension(230, 0)); textField.setText(kv.getValue().value); textField.setLineWrap(true); textField.setWrapStyleWord(true); innerPanel.add(textField, "wrap, width :300:"); textField.addKeyListener(new KeyAdapter() { @Override public void keyPressed(KeyEvent e) { if (e.getKeyCode() == KeyEvent.VK_TAB) { if (e.getModifiers() > 0) { textField.transferFocusBackward(); } else { textField.transferFocus(); } e.consume(); } } }); tabobjects.add(textField); } else if (datatype.equals("LangString")) { JScrollPane inner_scroll = new javax.swing.JScrollPane(); inner_scroll.setHorizontalScrollBarPolicy( javax.swing.ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); inner_scroll.setVerticalScrollBarPolicy( javax.swing.ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED); inner_scroll.setPreferredSize(new Dimension(240, 80)); inner_scroll.setName("langStringScroll"); final JTextArea jTextArea1 = new javax.swing.JTextArea(); jTextArea1.setName("MID_" + Integer.toString(kv.getValue().MID)); jTextArea1.setText(kv.getValue().value); jTextArea1.setSize(new Dimension(350, 70)); jTextArea1.setLineWrap(true); jTextArea1.setWrapStyleWord(true); inner_scroll.setViewportView(jTextArea1); innerPanel.add(inner_scroll, "width :300:"); //Add combo language box JComboBox voc = getComboLangBox(kv.getValue().language); voc.setName("MID_" + Integer.toString(kv.getValue().MID) + "_lang"); voc.setPreferredSize(new Dimension(200, 20)); innerPanel.add(voc, "wrap, width :300:"); jTextArea1.addKeyListener(new KeyAdapter() { @Override public void keyPressed(KeyEvent e) { if (e.getKeyCode() == KeyEvent.VK_TAB) { if (e.getModifiers() > 0) { jTextArea1.transferFocusBackward(); } else { jTextArea1.transferFocus(); } e.consume(); } } }); tabobjects.add(jTextArea1); tabobjects.add(voc); } else if (datatype.equals("Language")) { final JComboBox voc = getComboLangBox(kv.getValue().value); voc.setName("MID_" + Integer.toString(kv.getValue().MID)); voc.setPreferredSize(new Dimension(150, 20)); voc.setBounds(5, 5, 150, 20); innerPanel.add(voc, "wrap, width :500:"); //BookImporter.policy.addIndexedComponent(voc); tabobjects.add(voc); } else if (datatype.equals("Boolean")) { int selected = 0; TreeMap bin = new TreeMap<String, String>(); bin.put("yes", Utility.getBundleString("voc1", bundle)); bin.put("no", Utility.getBundleString("voc2", bundle)); if (kv.getValue().value == null) { switch (kv.getValue().MID) { case 35: selected = 0; break; case 36: selected = 1; break; } } else if (kv.getValue().value.equals("yes")) { selected = 1; } else { selected = 0; } final ComboMapImpl model = new ComboMapImpl(); model.putAll(bin); final JComboBox voc = new javax.swing.JComboBox(model); model.specialRenderCombo(voc); voc.setName("MID_" + Integer.toString(kv.getValue().MID)); voc.setSelectedIndex(selected); voc.setPreferredSize(new Dimension(150, 20)); voc.setBounds(5, 5, 150, 20); innerPanel.add(voc, "wrap, width :300:"); //BookImporter.policy.addIndexedComponent(voc); tabobjects.add(voc); } else if (datatype.equals("License")) { String selectedIndex = null; int vindex = 0; int defaultIndex = 0; TreeMap<String, String> entryCombo = new TreeMap<String, String>(); for (Map.Entry<String, TreeMap<String, VocEntry>> vc : vocabularies.entrySet()) { if (vc.getKey().equals(Integer.toString(kv.getValue().MID))) { TreeMap<String, VocEntry> iEntry = vc.getValue(); for (Map.Entry<String, VocEntry> ivc : iEntry.entrySet()) { entryCombo.put(ivc.getValue().description, ivc.getValue().ID); if (ivc.getValue().ID.equals("1")) defaultIndex = vindex; if (kv.getValue().value != null) { if (ivc.getValue().ID.equals(kv.getValue().value)) { selectedIndex = Integer.toString(vindex); } } vindex++; } } } if (selectedIndex == null) selectedIndex = Integer.toString(defaultIndex); ComboMapImpl model = new ComboMapImpl(); model.putAll(entryCombo); model.setVocabularyCombo(true); JComboBox voc = new javax.swing.JComboBox(model); model.specialRenderCombo(voc); voc.setName("MID_" + Integer.toString(kv.getValue().MID)); voc.setSelectedIndex(Integer.parseInt(selectedIndex)); voc.setPreferredSize(new Dimension(150, 20)); voc.setBounds(5, 5, 150, 20); innerPanel.add(voc, "wrap, width :500:"); //BookImporter.policy.addIndexedComponent(voc); tabobjects.add(voc); } else if (datatype.equals("DateTime")) { //final JXDatePicker datePicker = new JXDatePicker(); JDateChooser datePicker = new JDateChooser(); datePicker.setName("MID_" + Integer.toString(kv.getValue().MID)); JPanel test = new JPanel(new MigLayout()); JLabel lbefore = new JLabel(Utility.getBundleString("beforechristlabel", bundle)); JCheckBox beforechrist = new JCheckBox(); beforechrist.setName("MID_" + Integer.toString(kv.getValue().MID) + "_check"); if (kv.getValue().value != null) { try { if (kv.getValue().value.charAt(0) == '-') { beforechrist.setSelected(true); } Date date1 = new Date(); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); if (kv.getValue().value.charAt(0) == '-') { date1 = sdf.parse(adjustDate(kv.getValue().value)); } else { date1 = sdf.parse(kv.getValue().value); } datePicker.setDate(date1); } catch (Exception e) { //Console.WriteLine("ERROR import date:" + ex.Message); } } test.add(datePicker, "width :200:"); test.add(lbefore, "gapleft 30"); test.add(beforechrist, "wrap"); innerPanel.add(test, "wrap"); } } //Recursive call create_metadata_view(kv.getValue().submetadatas, innerPanel, level + 1, panelname); if (kv.getValue().editable.equals("Y") || (datatype.equals("Node") && kv.getValue().hidden.equals("0"))) { parent.add(innerPanel, "wrap, growx"); for (Component tabobject : tabobjects) { BookImporter.policy.addIndexedComponent(tabobject); } } } }
From source file:org.argouml.application.Main.java
/** * Do a part of the initialization that is very much GUI-stuff. * * @param splash the splash screeen/* ww w.ja v a2 s .c o m*/ */ private static ProjectBrowser initializeGUI(SplashScreen splash) { // make the projectbrowser JPanel todoPane = new ToDoPane(); ProjectBrowser pb = ProjectBrowser.makeInstance(splash, true, todoPane); JOptionPane.setRootFrame(pb); pb.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); // Set the screen layout to what the user left it before, or // to reasonable defaults. Rectangle scrSize = GraphicsEnvironment.getLocalGraphicsEnvironment().getMaximumWindowBounds(); int configFrameWidth = Configuration.getInteger(Argo.KEY_SCREEN_WIDTH, scrSize.width); int w = Math.min(configFrameWidth, scrSize.width); if (w == 0) { w = 600; } int configFrameHeight = Configuration.getInteger(Argo.KEY_SCREEN_HEIGHT, scrSize.height); int h = Math.min(configFrameHeight, scrSize.height); if (h == 0) { h = 400; } int x = Configuration.getInteger(Argo.KEY_SCREEN_LEFT_X, 0); int y = Configuration.getInteger(Argo.KEY_SCREEN_TOP_Y, 0); pb.setLocation(x, y); pb.setSize(w, h); pb.setExtendedState( Configuration.getBoolean(Argo.KEY_SCREEN_MAXIMIZED, false) ? Frame.MAXIMIZED_BOTH : Frame.NORMAL); UIManager.put("Button.focusInputMap", new UIDefaults.LazyInputMap(new Object[] { "ENTER", "pressed", "released ENTER", "released", "SPACE", "pressed", "released SPACE", "released" })); return pb; }
From source file:com.signalcollect.sna.visualization.SignalCollectSNATopComponent.java
/** * Executes the label propagation algorithm * * @param evt//from w w w . ja v a2s. c o m */ private void labelPropagationButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_labelPropagationButtonActionPerformed try { mainPanel.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); if (jTextPane1.getText() == null) { throw new IllegalArgumentException("No input found!"); } if (Integer.parseInt(jTextPane1.getText()) < 1) { throw new IllegalArgumentException("The number has to be greater than 0"); } scgc = new LabelPropagationSignalCollectGephiConnectorImpl(fileName, scala.Option.apply(Integer.parseInt(jTextPane1.getText()))); scgc.getLabelPropagation(); } catch (IllegalArgumentException exception) { JOptionPane.showMessageDialog(messageFrame, "Error when parsing input " + jTextPane1.getText() + ": " + exception.getMessage(), "Signal/Collect Error", JOptionPane.ERROR_MESSAGE); } catch (Exception exception) { messageFrame = new JFrame(); exception.printStackTrace(); JOptionPane.showMessageDialog(messageFrame, "Technical exception happened (" + exception.getCause() + ")", "Signal/Collect Error", JOptionPane.ERROR_MESSAGE); } finally { scgc = null; mainPanel.setCursor(Cursor.getDefaultCursor()); } }
From source file:com.rapidminer.gui.viewer.metadata.AttributeStatisticsPanel.java
/** * Initializes the GUI.//w ww . j av a 2 s. c om * */ @SuppressWarnings({ "unchecked", "rawtypes" }) private void initGUI() { setLayout(new GridBagLayout()); GridBagConstraints gbc = new GridBagConstraints(); // add attribute name panelAttName = new JPanel(); panelAttName.setLayout(new BoxLayout(panelAttName, BoxLayout.PAGE_AXIS)); panelAttName.setOpaque(false); // this border is to visualize that the name column can be enlarged/shrinked panelAttName.setBorder(BorderFactory.createMatteBorder(0, 0, 0, 1, Color.LIGHT_GRAY)); labelAttHeader = new JLabel(LABEL_DOTS); labelAttHeader.setFont(labelAttHeader.getFont().deriveFont(FONT_SIZE_LABEL_HEADER)); labelAttHeader.setForeground(Color.GRAY); panelAttName.add(labelAttHeader); labelAttName = new JLabel(LABEL_DOTS); labelAttName.setFont(labelAttName.getFont().deriveFont(Font.BOLD, FONT_SIZE_LABEL_VALUE)); labelAttName.setMinimumSize(DIMENSION_LABEL_ATTRIBUTE); labelAttName.setPreferredSize(DIMENSION_LABEL_ATTRIBUTE); panelAttName.add(labelAttName); gbc.gridx = 0; gbc.gridy = 0; gbc.insets = new Insets(3, 20, 3, 10); gbc.anchor = GridBagConstraints.CENTER; gbc.fill = GridBagConstraints.HORIZONTAL; gbc.weightx = 0.0; gbc.weighty = 1.0; gbc.gridheight = 2; add(panelAttName, gbc); // create value type name and bring it to a nice to read format (aka uppercase first letter // and replace '_' with ' ' gbc.gridx += 1; gbc.insets = new Insets(5, 15, 5, 10); labelAttType = new JLabel(LABEL_DOTS); labelAttType.setMinimumSize(DIMENSION_LABEL_TYPE); labelAttType.setPreferredSize(DIMENSION_LABEL_TYPE); add(labelAttType, gbc); // missings panel JPanel panelStatsMissing = new JPanel(); panelStatsMissing.setLayout(new BoxLayout(panelStatsMissing, BoxLayout.PAGE_AXIS)); panelStatsMissing.setOpaque(false); labelStatsMissing = new JLabel(LABEL_DOTS); labelStatsMissing.setMinimumSize(DIMENSION_LABEL_MISSINGS); labelStatsMissing.setPreferredSize(DIMENSION_LABEL_MISSINGS); panelStatsMissing.add(labelStatsMissing); gbc.gridx += 1; gbc.fill = GridBagConstraints.NONE; gbc.weightx = 0.0; add(panelStatsMissing, gbc); // chart panel(s) (only visible when enlarged) JPanel chartPanel = new JPanel(new BorderLayout()); chartPanel.setBackground(COLOR_TRANSPARENT); chartPanel.setOpaque(false); listOfChartPanels.add(chartPanel); updateVisibilityOfChartPanels(); gbc.fill = GridBagConstraints.NONE; gbc.weighty = 0.0; gbc.insets = new Insets(0, 10, 0, 10); for (JPanel panel : listOfChartPanels) { gbc.gridx += 1; add(panel, gbc); } // (hidden) construction panel String constructionLabel = I18N.getMessage(I18N.getGUIBundle(), "gui.label.attribute_statistics.statistics.construction.label"); panelStatsConstruction = new JPanel(); panelStatsConstruction.setLayout(new BoxLayout(panelStatsConstruction, BoxLayout.PAGE_AXIS)); panelStatsConstruction.setOpaque(false); panelStatsConstruction.setVisible(false); JLabel labelConstructionHeader = new JLabel(constructionLabel); labelConstructionHeader.setFont(labelConstructionHeader.getFont().deriveFont(FONT_SIZE_LABEL_HEADER)); labelConstructionHeader.setForeground(Color.GRAY); panelStatsConstruction.add(labelConstructionHeader); labelStatsConstruction = new JLabel(LABEL_DOTS); labelStatsConstruction.setFont(labelStatsConstruction.getFont().deriveFont(FONT_SIZE_LABEL_VALUE)); labelStatsConstruction.setMinimumSize(DIMENSION_LABEL_CONSTRUCTION); labelStatsConstruction.setPreferredSize(DIMENSION_LABEL_CONSTRUCTION); panelStatsConstruction.add(labelStatsConstruction); gbc.gridx += 1; gbc.fill = GridBagConstraints.NONE; gbc.weightx = 0.0; add(panelStatsConstruction, gbc); // statistics panel, contains different statistics panels for numerical/nominal/date_time on // a card layout // needed to switch between for model swapping cardStatsPanel = new JPanel(); cardStatsPanel.setOpaque(false); cardLayout = new CardLayout(); cardStatsPanel.setLayout(cardLayout); // numerical version JPanel statsNumPanel = new JPanel(); GridBagLayout layout = new GridBagLayout(); GridBagConstraints gbcStatPanel = new GridBagConstraints(); statsNumPanel.setLayout(layout); statsNumPanel.setOpaque(false); String avgLabel = I18N.getMessage(I18N.getGUIBundle(), "gui.label.attribute_statistics.statistics.avg.label"); String devianceLabel = I18N.getMessage(I18N.getGUIBundle(), "gui.label.attribute_statistics.statistics.variance.label"); String minLabel = I18N.getMessage(I18N.getGUIBundle(), "gui.label.attribute_statistics.statistics.min.label"); String maxLabel = I18N.getMessage(I18N.getGUIBundle(), "gui.label.attribute_statistics.statistics.max.label"); // min value panel JPanel panelStatsMin = new JPanel(); panelStatsMin.setLayout(new BoxLayout(panelStatsMin, BoxLayout.PAGE_AXIS)); panelStatsMin.setOpaque(false); JLabel labelMinHeader = new JLabel(minLabel); labelMinHeader.setFont(labelMinHeader.getFont().deriveFont(FONT_SIZE_LABEL_HEADER)); labelMinHeader.setForeground(Color.GRAY); panelStatsMin.add(labelMinHeader); labelStatsMin = new JLabel(LABEL_DOTS); labelStatsMin.setFont(labelStatsMin.getFont().deriveFont(FONT_SIZE_LABEL_VALUE)); panelStatsMin.add(labelStatsMin); // max value panel JPanel panelStatsMax = new JPanel(); panelStatsMax.setLayout(new BoxLayout(panelStatsMax, BoxLayout.PAGE_AXIS)); panelStatsMax.setOpaque(false); JLabel labelMaxHeader = new JLabel(maxLabel); labelMaxHeader.setFont(labelMaxHeader.getFont().deriveFont(FONT_SIZE_LABEL_HEADER)); labelMaxHeader.setForeground(Color.GRAY); panelStatsMax.add(labelMaxHeader); labelStatsMax = new JLabel(LABEL_DOTS); labelStatsMax.setFont(labelStatsMax.getFont().deriveFont(FONT_SIZE_LABEL_VALUE)); panelStatsMax.add(labelStatsMax); // average value panel JPanel panelStatsAvg = new JPanel(); panelStatsAvg.setLayout(new BoxLayout(panelStatsAvg, BoxLayout.PAGE_AXIS)); panelStatsAvg.setOpaque(false); JLabel labelAvgHeader = new JLabel(avgLabel); labelAvgHeader.setFont(labelAvgHeader.getFont().deriveFont(FONT_SIZE_LABEL_HEADER)); labelAvgHeader.setForeground(Color.GRAY); panelStatsAvg.add(labelAvgHeader); labelStatsAvg = new JLabel(LABEL_DOTS); labelStatsAvg.setFont(labelStatsAvg.getFont().deriveFont(FONT_SIZE_LABEL_VALUE)); panelStatsAvg.add(labelStatsAvg); // deviance value panel JPanel panelStatsDeviance = new JPanel(); panelStatsDeviance.setLayout(new BoxLayout(panelStatsDeviance, BoxLayout.PAGE_AXIS)); panelStatsDeviance.setOpaque(false); JLabel labelDevianceHeader = new JLabel(devianceLabel); labelDevianceHeader.setFont(labelDevianceHeader.getFont().deriveFont(FONT_SIZE_LABEL_HEADER)); labelDevianceHeader.setForeground(Color.GRAY); panelStatsDeviance.add(labelDevianceHeader); labelStatsDeviation = new JLabel(LABEL_DOTS); labelStatsDeviation.setFont(labelStatsDeviation.getFont().deriveFont(FONT_SIZE_LABEL_VALUE)); panelStatsDeviance.add(labelStatsDeviation); // add sub panels to stats panel gbcStatPanel.gridx = 0; gbcStatPanel.weightx = 0.0; gbcStatPanel.fill = GridBagConstraints.NONE; gbcStatPanel.insets = new Insets(0, 0, 0, 4); panelStatsMin.setPreferredSize(DIMENSION_PANEL_NUMERIC_PREF_SIZE); statsNumPanel.add(panelStatsMin, gbcStatPanel); gbcStatPanel.gridx += 1; panelStatsMax.setPreferredSize(DIMENSION_PANEL_NUMERIC_PREF_SIZE); statsNumPanel.add(panelStatsMax, gbcStatPanel); gbcStatPanel.gridx += 1; panelStatsAvg.setPreferredSize(DIMENSION_PANEL_NUMERIC_PREF_SIZE); statsNumPanel.add(panelStatsAvg, gbcStatPanel); gbcStatPanel.gridx += 1; panelStatsDeviance.setPreferredSize(DIMENSION_PANEL_NUMERIC_PREF_SIZE); statsNumPanel.add(panelStatsDeviance, gbcStatPanel); gbcStatPanel.gridx += 1; gbcStatPanel.weightx = 1.0; gbcStatPanel.fill = GridBagConstraints.HORIZONTAL; statsNumPanel.add(new JLabel(), gbcStatPanel); cardStatsPanel.add(statsNumPanel, CARD_NUMERICAL); // nominal version JPanel statsNomPanel = new JPanel(); statsNomPanel.setLayout(layout); statsNomPanel.setOpaque(false); String leastLabel = I18N.getMessage(I18N.getGUIBundle(), "gui.label.attribute_statistics.statistics.least.label"); String mostLabel = I18N.getMessage(I18N.getGUIBundle(), "gui.label.attribute_statistics.statistics.most.label"); String valuesLabel = I18N.getMessage(I18N.getGUIBundle(), "gui.label.attribute_statistics.statistics.values.label"); // least panel JPanel panelStatsLeast = new JPanel(); panelStatsLeast.setLayout(new BoxLayout(panelStatsLeast, BoxLayout.PAGE_AXIS)); panelStatsLeast.setOpaque(false); JLabel labelLeastHeader = new JLabel(leastLabel); labelLeastHeader.setFont(labelLeastHeader.getFont().deriveFont(FONT_SIZE_LABEL_HEADER)); labelLeastHeader.setForeground(Color.GRAY); labelLeastHeader.setAlignmentX(Component.LEFT_ALIGNMENT); panelStatsLeast.add(labelLeastHeader); labelStatsLeast = new JLabel(LABEL_DOTS); labelStatsLeast.setFont(labelStatsLeast.getFont().deriveFont(FONT_SIZE_LABEL_VALUE)); panelStatsLeast.add(labelStatsLeast); // most panel JPanel panelStatsMost = new JPanel(); panelStatsMost.setLayout(new BoxLayout(panelStatsMost, BoxLayout.PAGE_AXIS)); panelStatsMost.setOpaque(false); JLabel labelMostHeader = new JLabel(mostLabel); labelMostHeader.setFont(labelMostHeader.getFont().deriveFont(FONT_SIZE_LABEL_HEADER)); labelMostHeader.setForeground(Color.GRAY); labelMostHeader.setAlignmentX(Component.LEFT_ALIGNMENT); panelStatsMost.add(labelMostHeader); labelStatsMost = new JLabel(LABEL_DOTS); labelStatsMost.setFont(labelStatsMost.getFont().deriveFont(FONT_SIZE_LABEL_VALUE)); panelStatsMost.add(labelStatsMost); // values panel JPanel panelStatsValues = new JPanel(); panelStatsValues.setLayout(new BoxLayout(panelStatsValues, BoxLayout.PAGE_AXIS)); panelStatsValues.setOpaque(false); JLabel labelValuesHeader = new JLabel(valuesLabel); labelValuesHeader.setFont(labelValuesHeader.getFont().deriveFont(FONT_SIZE_LABEL_HEADER)); labelValuesHeader.setForeground(Color.GRAY); labelValuesHeader.setAlignmentX(Component.LEFT_ALIGNMENT); panelStatsValues.add(labelValuesHeader); labelStatsValues = new JLabel(LABEL_DOTS); labelStatsValues.setFont(labelStatsValues.getFont().deriveFont(FONT_SIZE_LABEL_VALUE)); panelStatsValues.add(labelStatsValues); detailsButton = new JButton(new ShowNomValueAction(this)); detailsButton.setVisible(false); detailsButton.setOpaque(false); detailsButton.setContentAreaFilled(false); detailsButton.setBorderPainted(false); detailsButton.addMouseListener(enlargeAndHoverAndPopupMouseAdapter); detailsButton.setHorizontalAlignment(SwingConstants.LEFT); detailsButton.setHorizontalTextPosition(SwingConstants.LEFT); detailsButton.setIcon(null); Font font = detailsButton.getFont(); Map attributes = font.getAttributes(); attributes.put(TextAttribute.UNDERLINE, TextAttribute.UNDERLINE_ON); detailsButton.setFont(font.deriveFont(attributes)); panelStatsValues.add(detailsButton); // add sub panel to stats panel gbcStatPanel.gridx = 0; gbcStatPanel.weightx = 0.0; gbcStatPanel.fill = GridBagConstraints.NONE; gbcStatPanel.insets = new Insets(0, 0, 0, 6); panelStatsLeast.setPreferredSize(DIMENSION_PANEL_NOMINAL_PREF_SIZE); statsNomPanel.add(panelStatsLeast, gbcStatPanel); gbcStatPanel.gridx += 1; panelStatsMost.setPreferredSize(DIMENSION_PANEL_NOMINAL_PREF_SIZE); statsNomPanel.add(panelStatsMost, gbcStatPanel); gbcStatPanel.gridx += 1; statsNomPanel.add(panelStatsValues, gbcStatPanel); gbcStatPanel.gridx += 1; gbcStatPanel.weightx = 1.0; gbcStatPanel.fill = GridBagConstraints.HORIZONTAL; statsNomPanel.add(new JLabel(), gbcStatPanel); cardStatsPanel.add(statsNomPanel, CARD_NOMINAL); // date_time version JPanel statsDateTimePanel = new JPanel(); statsDateTimePanel.setLayout(layout); statsDateTimePanel.setOpaque(false); String durationLabel = I18N.getMessage(I18N.getGUIBundle(), "gui.label.attribute_statistics.statistics.duration.label"); String fromLabel = I18N.getMessage(I18N.getGUIBundle(), "gui.label.attribute_statistics.statistics.from.label"); String untilLabel = I18N.getMessage(I18N.getGUIBundle(), "gui.label.attribute_statistics.statistics.until.label"); // min value panel JPanel panelStatsFrom = new JPanel(); panelStatsFrom.setLayout(new BoxLayout(panelStatsFrom, BoxLayout.PAGE_AXIS)); panelStatsFrom.setOpaque(false); JLabel labelFromHeader = new JLabel(fromLabel); labelFromHeader.setFont(labelFromHeader.getFont().deriveFont(FONT_SIZE_LABEL_HEADER)); labelFromHeader.setForeground(Color.GRAY); panelStatsFrom.add(labelFromHeader); labelStatsFrom = new JLabel(LABEL_DOTS); labelStatsFrom.setFont(labelStatsFrom.getFont().deriveFont(FONT_SIZE_LABEL_VALUE)); panelStatsFrom.add(labelStatsFrom); // until value panel JPanel panelStatsUntil = new JPanel(); panelStatsUntil.setLayout(new BoxLayout(panelStatsUntil, BoxLayout.PAGE_AXIS)); panelStatsUntil.setOpaque(false); JLabel labelUntilHeader = new JLabel(untilLabel); labelUntilHeader.setFont(labelUntilHeader.getFont().deriveFont(FONT_SIZE_LABEL_HEADER)); labelUntilHeader.setForeground(Color.GRAY); panelStatsUntil.add(labelUntilHeader); labelStatsUntil = new JLabel(LABEL_DOTS); labelStatsUntil.setFont(labelStatsUntil.getFont().deriveFont(FONT_SIZE_LABEL_VALUE)); panelStatsUntil.add(labelStatsUntil); // duration value panel JPanel panelStatsDuration = new JPanel(); panelStatsDuration.setLayout(new BoxLayout(panelStatsDuration, BoxLayout.PAGE_AXIS)); panelStatsDuration.setOpaque(false); JLabel labelDurationHeader = new JLabel(durationLabel); labelDurationHeader.setFont(labelDurationHeader.getFont().deriveFont(FONT_SIZE_LABEL_HEADER)); labelDurationHeader.setForeground(Color.GRAY); panelStatsDuration.add(labelDurationHeader); labelStatsDuration = new JLabel(LABEL_DOTS); labelStatsDuration.setFont(labelStatsDuration.getFont().deriveFont(FONT_SIZE_LABEL_VALUE)); panelStatsDuration.add(labelStatsDuration); // add sub panels to stats panel gbcStatPanel.gridx = 0; gbcStatPanel.weightx = 0.0; gbcStatPanel.fill = GridBagConstraints.NONE; gbcStatPanel.insets = new Insets(0, 0, 0, 6); panelStatsFrom.setPreferredSize(DIMENSION_PANEL_DATE_PREF_SIZE); statsDateTimePanel.add(panelStatsFrom, gbcStatPanel); gbcStatPanel.gridx += 1; panelStatsUntil.setPreferredSize(DIMENSION_PANEL_DATE_PREF_SIZE); statsDateTimePanel.add(panelStatsUntil, gbcStatPanel); gbcStatPanel.gridx += 1; panelStatsDuration.setPreferredSize(DIMENSION_PANEL_DATE_PREF_SIZE); statsDateTimePanel.add(panelStatsDuration, gbcStatPanel); gbcStatPanel.gridx += 1; gbcStatPanel.weightx = 1.0; gbcStatPanel.fill = GridBagConstraints.HORIZONTAL; statsDateTimePanel.add(new JLabel(), gbcStatPanel); cardStatsPanel.add(statsDateTimePanel, CARD_DATE_TIME); // add stats panel to main gui gbc.gridx += 1; gbc.insets = new Insets(5, 10, 5, 10); gbc.fill = GridBagConstraints.HORIZONTAL; gbc.weightx = 1.0; gbc.weighty = 0.0; gbc.anchor = GridBagConstraints.WEST; add(cardStatsPanel, gbc); // needed so we can draw our own background setOpaque(false); // handle mouse events for hover effect and enlarging/shrinking addMouseListener(enlargeAndHoverAndPopupMouseAdapter); // change cursor to indicate this component can be clicked setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); }
From source file:com.nbt.TreeFrame.java
public void doImportDat(final File file) { Cursor waitCursor = Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR); setCursor(waitCursor);/*w w w . ja va2 s . c o m*/ SwingWorkerUnlimited.execure(new SwingWorker<CompoundTag, Void>() { @Override protected CompoundTag doInBackground() throws Exception { NBTInputStream ns = null; try { ns = new NBTInputStream(new FileInputStream(file)); return (CompoundTag) ns.readTag(); } finally { IOUtils.closeQuietly(ns); } } @Override protected void done() { CompoundTag tag = null; try { tag = get(); } catch (InterruptedException e) { e.printStackTrace(); } catch (ExecutionException e) { e.printStackTrace(); Throwable cause = ExceptionUtils.getRootCause(e); showErrorDialog(cause.getMessage()); return; } textFile.setText(file.getAbsolutePath()); updateTreeTable(tag); Cursor defaultCursor = Cursor.getDefaultCursor(); setCursor(defaultCursor); } }); }
From source file:ca.phon.ipamap.IpaMap.java
private JXButton getToggleButton(Grid grid, JXCollapsiblePane cp) { Action toggleAction = cp.getActionMap().get(JXCollapsiblePane.TOGGLE_ACTION); // use the collapse/expand icons from the JTree UI toggleAction.putValue(JXCollapsiblePane.COLLAPSE_ICON, UIManager.getIcon("Tree.expandedIcon")); toggleAction.putValue(JXCollapsiblePane.EXPAND_ICON, UIManager.getIcon("Tree.collapsedIcon")); toggleAction.putValue(Action.NAME, grid.getName()); JXButton btn = new JXButton(toggleAction) { @Override//from w w w . j av a 2 s .c o m public Insets getInsets() { Insets retVal = super.getInsets(); retVal.top = 0; retVal.bottom = 0; return retVal; } @Override public Dimension getPreferredSize() { return new Dimension(0, 20); } }; btn.setHorizontalAlignment(SwingConstants.LEFT); btn.setBackgroundPainter(new Painter<JXButton>() { @Override public void paint(Graphics2D g, JXButton object, int width, int height) { MattePainter mp = new MattePainter(UIManager.getColor("Button.background")); mp.paint(g, object, width, height); } }); btn.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); btn.setBorderPainted(false); btn.setFocusable(false); btn.putClientProperty("JComponent.sizeVariant", "small"); btn.revalidate(); return btn; }
From source file:edu.harvard.mcz.imagecapture.MainFrame.java
public void setSpecimenBrowseList(Specimen searchCriteria) { Singleton.getSingletonInstance().getMainFrame().setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); slb = new SpecimenBrowser(searchCriteria, true); if (ilb != null) { jPanelCenter.remove(ilb);/*w w w. j a va 2 s . c o m*/ } if (ulb != null) { jPanelCenter.remove(ulb); } jPanelCenter.removeAll(); jPanelCenter.add(slb, BorderLayout.CENTER); jPanelCenter.revalidate(); jPanelCenter.repaint(); if (Singleton.getSingletonInstance().getProperties().getProperties() .getProperty(ImageCaptureProperties.KEY_ENABLE_BROWSE).equals("false")) { jMenuItemBrowseSpecimens.setEnabled(false); jMenuItemBrowseImages.setEnabled(false); } else { jMenuItemBrowseSpecimens.setEnabled(true); jMenuItemBrowseImages.setEnabled(true); } setStatusMessage("Found " + slb.getRowCount() + " matching specimens"); Singleton.getSingletonInstance().getMainFrame() .setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); }
From source file:op.care.med.inventory.PnlInventory.java
private CollapsiblePane createCP4(final MedStock stock) { /***/*from w ww .j a v a2 s .c o m*/ * _ ____ ____ _ _ __ _ _ __ * ___ _ __ ___ __ _| |_ ___ / ___| _ \| || | / /__| |_ ___ ___| | _\ \ * / __| '__/ _ \/ _` | __/ _ \ | | |_) | || |_| / __| __/ _ \ / __| |/ /| | * | (__| | | __/ (_| | || __/ |___| __/|__ _| \__ \ || (_) | (__| < | | * \___|_| \___|\__,_|\__\___|\____|_| |_| | |___/\__\___/ \___|_|\_\| | * \_\ /_/ */ final String key = stock.getID() + ".xstock"; synchronized (cpMap) { if (!cpMap.containsKey(key)) { cpMap.put(key, new CollapsiblePane()); try { cpMap.get(key).setCollapsed(true); } catch (PropertyVetoException e) { e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates. } } cpMap.get(key).setName("stock"); BigDecimal sumStock = BigDecimal.ZERO; try { EntityManager em = OPDE.createEM(); sumStock = MedStockTools.getSum(em, stock); em.close(); } catch (Exception e) { OPDE.fatal(e); } String title = "<html><table border=\"0\">" + "<tr>" + (stock.isClosed() ? "<s>" : "") + "<td width=\"600\" align=\"left\">" + MedStockTools.getAsHTML(stock) + "</td>" + "<td width=\"200\" align=\"right\">" + NumberFormat.getNumberInstance().format(sumStock) + " " + DosageFormTools.getPackageText(MedInventoryTools.getForm(stock.getInventory())) + "</td>" + (stock.isClosed() ? "</s>" : "") + "</tr>" + "</table>" + "</html>"; DefaultCPTitle cptitle = new DefaultCPTitle(title, new ActionListener() { @Override public void actionPerformed(ActionEvent e) { try { cpMap.get(key).setCollapsed(!cpMap.get(key).isCollapsed()); } catch (PropertyVetoException pve) { // BAH! } } }); cpMap.get(key).setTitleLabelComponent(cptitle.getMain()); cpMap.get(key).setSlidingDirection(SwingConstants.SOUTH); cptitle.getRight().add(new StockPanel(stock)); if (!stock.getInventory().isClosed()) { /*** * ____ _ _ _ _ _ * | _ \ _ __(_)_ __ | |_| | __ _| |__ ___| | * | |_) | '__| | '_ \| __| | / _` | '_ \ / _ \ | * | __/| | | | | | | |_| |__| (_| | |_) | __/ | * |_| |_| |_|_| |_|\__|_____\__,_|_.__/ \___|_| * */ final JButton btnPrintLabel = new JButton(SYSConst.icon22print2); btnPrintLabel.setPressedIcon(SYSConst.icon22print2Pressed); btnPrintLabel.setAlignmentX(Component.RIGHT_ALIGNMENT); btnPrintLabel.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); btnPrintLabel.setContentAreaFilled(false); btnPrintLabel.setBorder(null); btnPrintLabel.setToolTipText(SYSTools.xx("nursingrecords.inventory.stock.btnprintlabel.tooltip")); btnPrintLabel.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent actionEvent) { LogicalPrinter logicalPrinter = OPDE.getLogicalPrinters().getMapName2LogicalPrinter() .get(OPDE.getProps().getProperty(SYSPropsTools.KEY_LOGICAL_PRINTER)); PrinterForm printerForm1 = logicalPrinter.getForms() .get(OPDE.getProps().getProperty(SYSPropsTools.KEY_MEDSTOCK_LABEL)); OPDE.getPrintProcessor().addPrintJob(new PrintListElement(stock, logicalPrinter, printerForm1, OPDE.getProps().getProperty(SYSPropsTools.KEY_PHYSICAL_PRINTER))); } }); btnPrintLabel.setEnabled(OPDE.getPrintProcessor().isWorking()); cptitle.getRight().add(btnPrintLabel); } /*** * __ __ * | \/ | ___ _ __ _ _ * | |\/| |/ _ \ '_ \| | | | * | | | | __/ | | | |_| | * |_| |_|\___|_| |_|\__,_| * */ final JButton btnMenu = new JButton(SYSConst.icon22menu); btnMenu.setPressedIcon(SYSConst.icon22Pressed); btnMenu.setAlignmentX(Component.RIGHT_ALIGNMENT); // btnMenu.setAlignmentY(Component.TOP_ALIGNMENT); btnMenu.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); btnMenu.setContentAreaFilled(false); btnMenu.setBorder(null); btnMenu.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { JidePopup popup = new JidePopup(); popup.setMovable(false); popup.getContentPane().setLayout(new BoxLayout(popup.getContentPane(), BoxLayout.LINE_AXIS)); popup.setOwner(btnMenu); popup.removeExcludedComponent(btnMenu); JPanel pnl = getMenu(stock); popup.getContentPane().add(pnl); popup.setDefaultFocusComponent(pnl); GUITools.showPopup(popup, SwingConstants.WEST); } }); cptitle.getRight().add(btnMenu); CollapsiblePaneAdapter adapter = new CollapsiblePaneAdapter() { @Override public void paneExpanded(CollapsiblePaneEvent collapsiblePaneEvent) { cpMap.get(key).setContentPane(createContentPanel4(stock)); } }; synchronized (cpListener) { if (cpListener.containsKey(key)) { cpMap.get(key).removeCollapsiblePaneListener(cpListener.get(key)); } cpListener.put(key, adapter); cpMap.get(key).addCollapsiblePaneListener(adapter); } if (!cpMap.get(key).isCollapsed()) { JPanel contentPane = createContentPanel4(stock); cpMap.get(key).setContentPane(contentPane); } cpMap.get(key).setHorizontalAlignment(SwingConstants.LEADING); cpMap.get(key).setOpaque(false); cpMap.get(key).setBackground( getColor(SYSConst.light3, lstInventories.indexOf(stock.getInventory()) % 2 != 0)); return cpMap.get(key); } }