/** * This function is used to re-run the analyser, and re-create the rows corresponding the its * results. */ private void refreshReviewTable() { reviewPanel.removeAll(); rows.clear(); GridBagLayout gbl = new GridBagLayout(); reviewPanel.setLayout(gbl); GridBagConstraints gbc = new GridBagConstraints(); gbc.fill = GridBagConstraints.HORIZONTAL; gbc.gridy = 0; try { Map<String, Long> sums = analyser.processLogFile(config.getLogFilename(), fromDate.getDate(), toDate.getDate()); for (Entry<String, Long> entry : sums.entrySet()) { String project = entry.getKey(); double hours = 1.0 * entry.getValue() / (1000 * 3600); addRow(gbl, gbc, project, hours); } for (String project : main.getProjectsTree().getTopLevelProjects()) if (!rows.containsKey(project)) addRow(gbl, gbc, project, 0); gbc.insets = new Insets(10, 0, 0, 0); addLeftLabel(gbl, gbc, "TOTAL"); gbc.gridx = 1; gbc.weightx = 1; totalLabel.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 3)); gbl.setConstraints(totalLabel, gbc); reviewPanel.add(totalLabel); gbc.weightx = 0; addRightLabel(gbl, gbc); } catch (IOException e) { e.printStackTrace(); } recomputeTotal(); pack(); }
public void stateChanged(ChangeEvent e) { JSpinner source = (JSpinner) e.getSource(); if (source.getName().equals("Hour")) { calendar.set(Calendar.HOUR_OF_DAY, getSelectedHour()); return; } if (source.getName().equals("Year")) { calendar.set(Calendar.YEAR, getSelectedYear()); dayPanel.removeAll(); this.flushWeekAndDayPanal(calendar); dayPanel.revalidate(); dayPanel.updateUI(); return; } if (source.getName().equals("Month")) { calendar.set(Calendar.MONTH, getSelectedMonth() - 1); dayPanel.removeAll(); this.flushWeekAndDayPanal(calendar); dayPanel.revalidate(); dayPanel.updateUI(); return; } }
// Fees update method private void updateFeesData(long id) { String columns[] = {"Course", "Fees Payed", "Total fees", "Installments"}; try { Database db = new Database(); panel_7.removeAll(); feestablemodel = new MyTableModel(db.getFeeData(id), columns); feestable = new JTable(feestablemodel); feestable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); feestable.getSelectionModel().addListSelectionListener(this); feesscrollpane = new JScrollPane(feestable); panel_7.add(feesscrollpane); // change fees payed label feespayedlabel.setText("Fees Payed"); feesduelabel.setText("Fees Due"); totalfeeslabel.setText("Total Fees"); panel_7.revalidate(); } catch (Exception e) { JOptionPane.showMessageDialog(this, e.getMessage(), null, JOptionPane.ERROR_MESSAGE); } }
public void buildPopulationBox() { rebuilding = true; populationBox.removeAll(); peopleList = new ArrayList<Object>(); famList = new ArrayList<Family>(); peopleList.addAll(ctxt.individualCensus); String plur = (peopleList.size() == 1 ? "" : "s"); populationBox.setLayout(new BoxLayout(populationBox, BoxLayout.PAGE_AXIS)); populationBox.setBorder( BorderFactory.createTitledBorder( BorderFactory.createLineBorder(Color.blue), "Current Population")); populationBox.setAlignmentX(0.5f); populationBox.add(Box.createRigidArea(new Dimension(8, 0))); indivLabel = new JLabel("Contains " + peopleList.size() + " Individual" + plur); indivLabel.setAlignmentX(0.5f); populationBox.add(indivLabel); if (peopleList.size() > 0) { JPanel indivBtnBox = new JPanel(); indivBtnBox.setLayout(new BoxLayout(indivBtnBox, BoxLayout.LINE_AXIS)); Dimension sizer2 = new Dimension(350, 50); String[] indMenu = genIndMenu(peopleList); indPick = new JComboBox(indMenu); indPick.addActionListener(listener); indPick.setActionCommand("view/edit person"); indPick.setMinimumSize(sizer2); indPick.setMaximumSize(sizer2); indPick.setBorder( BorderFactory.createTitledBorder( BorderFactory.createLineBorder(Color.blue), "View/Edit Person")); indivBtnBox.add(indPick); populationBox.add(indivBtnBox); } // end of if-any-people-exist famList.addAll(ctxt.familyCensus); // end of filtering deleted records plur = (famList.size() == 1 ? "y" : "ies"); famLabel = new JLabel("Contains " + famList.size() + " Famil" + plur); famLabel.setAlignmentX(0.5f); populationBox.add(Box.createRigidArea(new Dimension(0, 4))); populationBox.add(famLabel); if (famList.size() > 0) { JPanel famBtnBox = new JPanel(); famBtnBox.setLayout(new BoxLayout(famBtnBox, BoxLayout.LINE_AXIS)); Dimension sizer2 = new Dimension(350, 50); String[] famMenu = genFamMenu(famList); famPick = new JComboBox(famMenu); famPick.addActionListener(listener); famPick.setActionCommand("view/edit family"); famPick.setMinimumSize(sizer2); famPick.setMaximumSize(sizer2); famPick.setBorder( BorderFactory.createTitledBorder( BorderFactory.createLineBorder(Color.blue), "View/Edit Family")); famBtnBox.add(famPick); populationBox.add(famBtnBox); } // end of if-any-families-exist rebuilding = false; } // end of method buildPopulationBox
/** * Remove the currently display gui and insert the given one. * * @param comp The new gui. */ private void addToContents(JComponent comp) { handlerHolder.removeAll(); comp.setPreferredSize(new Dimension(200, 300)); handlerHolder.add(comp, BorderLayout.CENTER); if (myContents != null) { myContents.invalidate(); myContents.validate(); myContents.repaint(); } }
private void resetPanel() { cal = new GregorianCalendar( Integer.parseInt(yearSpi.getValue().toString()), monthBox.getSelectedIndex(), Integer.parseInt(lastLabel.getText())); startPoint_x = 20; startPoint_y = 10; panel.removeAll(); panel.repaint(); initCalPanel(); }
private void setToComponent(final JComponent cmp, final boolean requestFocus) { myMatchingCountPanel.removeAll(); myMatchingCountPanel.add(cmp, BorderLayout.CENTER); myMatchingCountPanel.revalidate(); myMatchingCountPanel.repaint(); if (requestFocus) { SwingUtilities.invokeLater( new Runnable() { public void run() { myPatternField.getTextField().requestFocusInWindow(); } }); } }
public void uninstallUI(JComponent c) { uninstallListeners(filechooser); uninstallComponents(filechooser); uninstallDefaults(filechooser); if (accessoryPanel != null) { accessoryPanel.removeAll(); } accessoryPanel = null; getFileChooser().removeAll(); handler = null; }
/** * Set the fields from the ProjectionClass * * @param projClass projection class to use */ private void setFieldsWithClassParams(ProjectionClass projClass) { // set the projection in the JComboBox String want = projClass.toString(); for (int i = 0; i < projClassCB.getItemCount(); i++) { ProjectionClass pc = (ProjectionClass) projClassCB.getItemAt(i); if (pc.toString().equals(want)) { projClassCB.setSelectedItem((Object) pc); break; } } // set the parameter fields paramPanel.removeAll(); paramPanel.setVisible(0 < projClass.paramList.size()); List widgets = new ArrayList(); for (int i = 0; i < projClass.paramList.size(); i++) { ProjectionParam pp = (ProjectionParam) projClass.paramList.get(i); // construct the label String name = pp.name; String text = ""; // Create a decent looking label for (int cIdx = 0; cIdx < name.length(); cIdx++) { char c = name.charAt(cIdx); if (cIdx == 0) { c = Character.toUpperCase(c); } else { if (Character.isUpperCase(c)) { text += " "; c = Character.toLowerCase(c); } } text += c; } widgets.add(GuiUtils.rLabel(text + ": ")); // text input field JTextField tf = new JTextField(); pp.setTextField(tf); tf.setColumns(12); widgets.add(tf); } GuiUtils.tmpInsets = new Insets(4, 4, 4, 4); JPanel widgetPanel = GuiUtils.doLayout(widgets, 2, GuiUtils.WT_N, GuiUtils.WT_N); paramPanel.add("North", widgetPanel); paramPanel.add("Center", GuiUtils.filler()); }
/* public void addMiniChart(Plugin p){ components.add(p); rebuild(); } public void removeMiniChart(Plugin p){ components.remove(p); rebuild(); } */ public void rebuild() { // remove everything from main panel mainpanel.removeAll(); GridBagLayout gbl = new GridBagLayout(); GridBagConstraints gbc = new GridBagConstraints(); mainpanel.setLayout(gbl); gbc.anchor = gbc.NORTHWEST; gbc.fill = gbc.BOTH; gbc.weightx = 1; gbc.gridx = 0; int i = 0; // add chart gbc.weighty = 1; gbc.gridy = i; gbl.setConstraints(chartPanel, gbc); mainpanel.add(chartPanel); // add all other plugins/components validate(); }
private void buildKitData(Kits selectedKit) { final int ST_SPACE = 25; kitDataPanel.removeAll(); Box container = Box.createVerticalBox(); setComponentSize(container, 400, PAGE_HEIGHT); JLabel kitID = new JLabel(Integer.toString(selectedKit.getKitID())); JLabel kitName = new JLabel(selectedKit.getName()); JLabel kitDesc = new JLabel(selectedKit.getDescription()); JLabel lp = new JLabel("----- Listed Parts -----"); // align elements to the left collum // all the arguments can be left as KitID.LEFT because we only need any instance of a JComponent // to use the LEFT keyword kitID.setHorizontalAlignment(kitID.LEFT); kitName.setHorizontalAlignment(kitID.LEFT); kitDesc.setHorizontalAlignment(kitID.LEFT); lp.setHorizontalAlignment(kitID.LEFT); // add elements to container container.add(kitID); container.add(kitName); container.add(kitDesc); container.add(Box.createVerticalStrut(ST_SPACE)); container.add(lp); // add part data TreeMap<Integer, Parts> kitParts = selectedKit.getListOfParts(); for (Integer i : kitParts.keySet()) { Parts selectedPart = kitParts.get(i); Box holder = Box.createHorizontalBox(); Box section1 = Box.createVerticalBox(); Box section2 = Box.createVerticalBox(); int imageIndex = selectedPart.getImageIndex(); String PID = Integer.toString(selectedPart.getPartNumber()); String PName = selectedPart.getName(); String PDesc = selectedPart.getDesc(); setComponentSize(holder, 400, 60); // add elements to section1 section1.add(new JLabel("Part " + i)); section1.add(new JLabel(images.getIcon(imageIndex - 1))); // add elements to section2 section2.add(new JLabel("Part #: " + PID)); section2.add(new JLabel("Part name: " + PName)); section2.add(new JLabel("Part desc: " + PDesc)); // add sections to holder holder.add(section1); holder.add(Box.createHorizontalStrut(ST_SPACE)); holder.add(section2); // add holder to container container.add(holder); } // add the build items to the container buildQuantity = new JTextField("Enter number of kits to build"); build = new JButton("Add to build queue"); setComponentSize(buildQuantity, 400, 20); setComponentSize(buildQuantity, 400, 20); build.addActionListener(this); container.add(buildQuantity); container.add(build); // add container to kitDataPanel kitDataPanel.add(container); kitDataPanel.revalidate(); }
public void clear() { SingleImagePanel.deconstructAllSingleImagePanelsInContainer(multiPanel); multiPanel.removeAll(); frame.getContentPane().validate(); frame.getContentPane().repaint(); }
/** * @param filenames * @exception Exception if internal error */ public void loadMultiPanelFromSpecifiedFiles(String filenames[]) throws Exception { int nFiles = filenames.length; SingleImagePanel imagePanels[] = new SingleImagePanel[nFiles]; String orientations[][] = new String[nFiles][]; String views[] = new String[nFiles]; String lateralityViewAndModifiers[] = new String[nFiles]; String lateralities[] = new String[nFiles]; int widths[] = new int[nFiles]; int heights[] = new int[nFiles]; PixelSpacing spacing[] = new PixelSpacing[nFiles]; String rowOrientations[] = new String[nFiles]; String columnOrientations[] = new String[nFiles]; HashMap eventContexts = new HashMap(); double maximumHorizontalExtentInMm = 0; double maximumVerticalExtentInMm = 0; StructuredReport sr[] = new StructuredReport[nFiles]; int nImages = 0; int nCAD = 0; ClassLoader classLoader = Thread.currentThread().getContextClassLoader(); for (int f = 0; f < nFiles; ++f) { try { String filename = filenames[f]; DicomInputStream distream = null; InputStream in = classLoader.getResourceAsStream(filename); if (in != null) { distream = new DicomInputStream(in); } else { distream = new DicomInputStream(new File(filename)); } AttributeList list = new AttributeList(); list.read(distream); if (list.isImage()) { int i = nImages++; System.err.println("IMAGE [" + i + "] is file " + f + " (" + filenames[f] + ")"); orientations[i] = getPatientOrientation(list); // System.err.println("IMAGE ["+i+"] orientation="+(orientations[i] == null && // orientations[i].length == 2 ? "" : (orientations[i][0] + " " + orientations[i][1]))); views[i] = getView(list); // System.err.println("IMAGE ["+i+"] view="+views[i]); lateralityViewAndModifiers[i] = getImageLateralityViewModifierAndViewModifier(list); // System.err.println("IMAGE ["+i+"] // lateralityViewAndModifiers="+lateralityViewAndModifiers[i]); // System.err.println("File "+filenames[f]+": "+lateralityViewAndModifiers[i]); lateralities[i] = getLaterality(list); // System.err.println("IMAGE ["+i+"] laterality="+lateralities[i]); spacing[i] = new PixelSpacing(list); // System.err.println("IMAGE ["+i+"] spacing="+spacing[i]); SourceImage sImg = new SourceImage(list); BufferedImage img = sImg.getBufferedImage(); widths[i] = sImg.getWidth(); heights[i] = sImg.getHeight(); boolean shareVOIEventsInStudy = false; // does not seem to work anyway, since adding VOITransform to panel constructor // :( EventContext eventContext = new EventContext(Integer.toString(i)); SingleImagePanel imagePanel = makeNewImagePanel(sImg, eventContext); imagePanel.setDemographicAndTechniqueAnnotations( new DemographicAndTechniqueAnnotations(list), "SansSerif", Font.PLAIN, 10, Color.pink); imagePanel.setOrientationAnnotations( new OrientationAnnotations(rowOrientations[i], columnOrientations[i]), "SansSerif", Font.PLAIN, 20, Color.pink); imagePanel.setPixelSpacingInSourceImage( spacing[i].getSpacing(), spacing[i].getDescription()); if (Attribute.getSingleStringValueOrEmptyString(list, TagFromName.VOILUTFunction) .equals("SIGMOID")) { imagePanel.setVOIFunctionToLogistic(); } imagePanels[i] = imagePanel; } else { throw new DicomException("Unsupported SOP Class in file " + filenames[f]); } } catch (Exception e) { // FileNotFoundException,IOException,DicomException e.printStackTrace(System.err); } } // int imagesPerRow = nImages; // i.e., 1 -> 1, 2 -> 1, 4 -> 4, 5 -> 4, 8 -> 4 // int imagesPerCol = 1; int imagesPerRow = nImages >= 8 ? 8 : nImages; // i.e., 1 -> 1, 2 -> 1, 4 -> 4, 5 -> 4, 8 -> 4 int imagesPerCol = (nImages - 1) / imagesPerRow + 1; // i.e., 1 -> 1, 2 -> 2, 4 -> 1, 5 -> 2, 8 -> 2 int singleWidth = frameWidth / imagesPerRow; int singleHeight = frameHeight / imagesPerCol; if (nImages == 1 && singleWidth > singleHeight) { singleWidth = singleWidth / 2; // use only half the screen for a single view and a landscape monitor } for (int i = 0; i < nImages; ++i) { DisplayedAreaSelection displayedAreaSelection = null; displayedAreaSelection = new DisplayedAreaSelection( widths[i], heights[i], 0, 0, widths[i], heights[i], true, // in case spacing was not supplied 0, 0, 0, 0, 0, false /*crop*/); imagePanels[i].setDisplayedAreaSelection(displayedAreaSelection); imagePanels[i].setPreTransformImageRelativeCoordinates(null); } SingleImagePanel.deconstructAllSingleImagePanelsInContainer(multiPanel); multiPanel.removeAll(); multiPanel.setLayout(new GridLayout(imagesPerCol, imagesPerRow)); multiPanel.setBackground(Color.black); for (int x = 0; x < imagesPerCol; ++x) { for (int y = 0; y < imagesPerRow; ++y) { int i = x * imagesPerRow + y; if (i < nImages) { imagePanels[i].setPreferredSize(new Dimension(singleWidth, singleHeight)); multiPanel.add(imagePanels[i]); } } } frame.getContentPane().validate(); frame.getContentPane().repaint(); }
// Method to update Table and related components private void update() { Database db = new Database(); String column[] = { "ID", "NAME", "GENDER", "GUARDIAN_ROLE", "GUARDIAN_NAME", "PRESENT_ADDRESS", "PRESENT_CITY", "PRESENT_PHONE" }; try { // Update table if (searchcombobox.getSelectedIndex() == 0 && allfieldcheckbox.isSelected()) { mytablemodel = new MyTableModel(db.getAllStudent(), db.getColumnNameFromStudent()); } else if (searchcombobox.getSelectedIndex() == 0 && !allfieldcheckbox.isSelected()) { mytablemodel = new MyTableModel(db.getSomeFieldsFromStudent(), column); } else if (searchcombobox.getSelectedIndex() == 1 && allfieldcheckbox.isSelected()) { String query = "SELECT * FROM Student WHERE NAME = \'" + searchtextfield.getText().trim() + "\'"; mytablemodel = new MyTableModel(db.getData(query), db.getColumnNameFromStudent()); } else if (searchcombobox.getSelectedIndex() == 1 && !allfieldcheckbox.isSelected()) { String query = "SELECT ID, NAME, GENDER, GUARDIAN_ROLE, GUARDIAN_NAME, PRESENT_ADDRESS, PRESENT_CITY, PRESENT_PHONE FROM Student WHERE NAME = \'" + searchtextfield.getText().trim() + "\'"; mytablemodel = new MyTableModel(db.getData(query), column); } else if (searchcombobox.getSelectedIndex() == 2 && allfieldcheckbox.isSelected()) { String query = "SELECT * FROM Student WHERE GUARDIAN_NAME = \'" + searchtextfield.getText().trim() + "\'"; mytablemodel = new MyTableModel(db.getData(query), db.getColumnNameFromStudent()); } else if (searchcombobox.getSelectedIndex() == 2 && !allfieldcheckbox.isSelected()) { String query = "SELECT ID, NAME, GENDER, GUARDIAN_ROLE, GUARDIAN_NAME, PRESENT_ADDRESS, PRESENT_CITY, PRESENT_PHONE FROM Student WHERE GUARDIAN_NAME = \'" + searchtextfield.getText().trim() + "\'"; mytablemodel = new MyTableModel(db.getData(query), column); } else if (searchcombobox.getSelectedIndex() == 3 && allfieldcheckbox.isSelected()) { String query = "SELECT * FROM Student WHERE ID = ANY(SELECT SID FROM Fee WHERE CID = ANY(SELECT ID FROM CourseInfo WHERE NAME = \'" + searchtextfield.getText().trim() + "\'))"; mytablemodel = new MyTableModel(db.getData(query), db.getColumnNameFromStudent()); } else if (searchcombobox.getSelectedIndex() == 3 && !allfieldcheckbox.isSelected()) { String query = "SELECT ID, NAME, GENDER, GUARDIAN_ROLE, GUARDIAN_NAME, PRESENT_ADDRESS, PRESENT_CITY, PRESENT_PHONE FROM Student WHERE ID = ANY(SELECT SID FROM Fee WHERE CID = ANY(SELECT ID FROM CourseInfo WHERE NAME = \'" + searchtextfield.getText().trim() + "\'))"; mytablemodel = new MyTableModel(db.getData(query), column); } else if (searchcombobox.getSelectedIndex() == 4 && allfieldcheckbox.isSelected()) { String query = "SELECT * FROM Student WHERE ID = ANY(SELECT SID FROM Fee WHERE TOTAL_FEES - FEES_PAYED >= 0)"; mytablemodel = new MyTableModel(db.getData(query), db.getColumnNameFromStudent()); } else { String query = "SELECT ID, NAME, GENDER, GUARDIAN_ROLE, GUARDIAN_NAME, PRESENT_ADDRESS, PRESENT_CITY, PRESENT_PHONE FROM Student WHERE ID = ANY(SELECT SID FROM Fee WHERE TOTAL_FEES - FEES_PAYED >= 0)"; mytablemodel = new MyTableModel(db.getData(query), column); } table = new JTable(mytablemodel); table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); // Add list selection listener to table table.getSelectionModel().addListSelectionListener(this); TableColumn col = null; for (int i = 3; i < table.getColumnCount(); i++) { col = table.getColumnModel().getColumn(i); col.setPreferredWidth(200); } scrollpane = new JScrollPane(table); panel_3.removeAll(); panel_3.add(scrollpane); // Update total student label int total = db.getTotalStudent(); totalstudentlabel.setText("Total Student = " + total); // Clear search combo box searchtextfield.setText(""); this.revalidate(); } catch (Exception e) { JOptionPane.showMessageDialog(this, e.getMessage(), "Error", JOptionPane.ERROR_MESSAGE); } }