public void actionPerformed(ActionEvent ae) { String action = ae.getActionCommand(); if (action.equals("refresh")) { routerThread = new Thread(this); routerThread.start(); } }
public void actionPerformed(ActionEvent evt) { String arg = evt.getActionCommand(); if (arg.equals("Ok")) { dispose(); } }
/** Handle menu events. */ public void actionPerformed(ActionEvent e) { if ((e.getSource() instanceof MenuItem)) { MenuItem item = (MenuItem) e.getSource(); String cmd = e.getActionCommand(); commandName = cmd; ImagePlus imp = null; if (item.getParent() == Menus.getOpenRecentMenu()) { new RecentOpener(cmd); // open image in separate thread return; } else if (item.getParent() == Menus.getPopupMenu()) { Object parent = Menus.getPopupMenu().getParent(); if (parent instanceof ImageCanvas) imp = ((ImageCanvas) parent).getImage(); } int flags = e.getModifiers(); hotkey = false; actionPerformedTime = System.currentTimeMillis(); long ellapsedTime = actionPerformedTime - keyPressedTime; if (cmd != null && (ellapsedTime >= 200L || !cmd.equals(lastKeyCommand))) { if ((flags & Event.ALT_MASK) != 0) IJ.setKeyDown(KeyEvent.VK_ALT); if ((flags & Event.SHIFT_MASK) != 0) IJ.setKeyDown(KeyEvent.VK_SHIFT); new Executer(cmd, imp); } lastKeyCommand = null; if (IJ.debugMode) IJ.log("actionPerformed: time=" + ellapsedTime + ", " + e); } }
/** handle button events. */ public void actionPerformed(ActionEvent e) { String cmd = e.getActionCommand(); if (cmd.equals("run")) { if (animator.isAnimating()) stop(); else start(); } else if (cmd.equals("transparancy")) { if (drawable != null) drawable.setOpaque(!checkBox.isSelected()); } }
public void actionPerformed(ActionEvent e) { String command = e.getActionCommand(); if (command.equals("standard")) setColorModelWRBB(); else if (command.equals("invert")) invertCM(); else if (command.equals("rainbow")) setColorModelRainbow(); else if (command.equals("grey")) setColorModelGrey(); else if (command.equals("swapBackground")) swapBackground(); updateColors(); }
/** * Controls the zoom menu bar * * @param a the ActionEvent */ public void actionPerformed(ActionEvent a) { if (a.getActionCommand().equals("Update")) { this.repaint(); } if (a.getActionCommand().equals("25%")) { this.zoom(.25); enableZoomItems(); twentyFive.setEnabled(false); } if (a.getActionCommand().equals("50%")) { this.zoom(.50); enableZoomItems(); fifty.setEnabled(false); } if (a.getActionCommand().equals("75%")) { this.zoom(.75); enableZoomItems(); seventyFive.setEnabled(false); } if (a.getActionCommand().equals("100%")) { this.zoom(1.0); enableZoomItems(); hundred.setEnabled(false); } if (a.getActionCommand().equals("150%")) { this.zoom(1.5); enableZoomItems(); hundredFifty.setEnabled(false); } if (a.getActionCommand().equals("200%")) { this.zoom(2.0); enableZoomItems(); twoHundred.setEnabled(false); } if (a.getActionCommand().equals("500%")) { this.zoom(5.0); enableZoomItems(); fiveHundred.setEnabled(false); } }
/*----------------------------------------------------*/ public void actionPerformed(ActionEvent evt) { String arg = evt.getActionCommand(); if (arg.equals("Next>")) { // 98/9/11 aa nsl_display_frame.addDisplayCanvas( var_sel_full_name, var_sel_info, plot_type_name, replace_canvas); } else if (arg.equals("Cancel")) { dispose(); } else if (arg.equals("<Back")) { /* TODO - bring back NslDimInput Window */ dispose(); } }
// ActionListener for events @Override public void actionPerformed(ActionEvent ae) { String actionCommand = ae.getActionCommand().toLowerCase(); if (actionCommand.equals("save")) { savePlotAsImage(); } else if (actionCommand.equals("print")) { printPlot(); } else if (actionCommand.equals("grid")) { if (gridOn) { gridOn = false; gridMi.setText("Turn On Grid"); } else if (!gridOn) { gridOn = true; gridMi.setText("Turn Off Grid"); } refresh(); } }
/** * Method declaration * * @param ev */ public void actionPerformed(ActionEvent ev) { String s = ev.getActionCommand(); if (s == null) { if (ev.getSource() instanceof MenuItem) { MenuItem i; s = ((MenuItem) ev.getSource()).getLabel(); } } if (s.equals("Execute")) { execute(); } else if (s.equals("Exit")) { windowClosing(null); } else if (s.equals("Transfer")) { Transfer.work(null); } else if (s.equals("Dump")) { Transfer.work(new String[] {"-d"}); /* NB - 26052002 Restore is not implemented yet in the transfer tool */ /* } else if (s.equals("Restore")) { Transfer.work(new String[]{"-r"}); */ } else if (s.equals("Logging on")) { jdbcSystem.setLogToSystem(true); } else if (s.equals("Logging off")) { jdbcSystem.setLogToSystem(false); } else if (s.equals("Refresh Tree")) { refreshTree(); } else if (s.startsWith("#")) { int i = Integer.parseInt(s.substring(1)); txtCommand.setText(sRecent[i]); } else if (s.equals("Connect...")) { connect(ConnectionDialog.createConnection(fMain, "Connect")); refreshTree(); } else if (s.equals("Results in Grid")) { iResult = 0; pResult.removeAll(); pResult.add("Center", gResult); pResult.doLayout(); } else if (s.equals("Open Script...")) { FileDialog f = new FileDialog(fMain, "Open Script", FileDialog.LOAD); // (ulrivo): set default directory if set from command line if (defDirectory != null) { f.setDirectory(defDirectory); } f.show(); String file = f.getFile(); if (file != null) { txtCommand.setText(DatabaseManagerCommon.readFile(f.getDirectory() + file)); } } else if (s.equals("Save Script...")) { FileDialog f = new FileDialog(fMain, "Save Script", FileDialog.SAVE); // (ulrivo): set default directory if set from command line if (defDirectory != null) { f.setDirectory(defDirectory); } f.show(); String file = f.getFile(); if (file != null) { DatabaseManagerCommon.writeFile(f.getDirectory() + file, txtCommand.getText()); } } else if (s.equals("Save Result...")) { FileDialog f = new FileDialog(fMain, "Save Result", FileDialog.SAVE); // (ulrivo): set default directory if set from command line if (defDirectory != null) { f.setDirectory(defDirectory); } f.show(); String file = f.getFile(); if (file != null) { showResultInText(); DatabaseManagerCommon.writeFile(f.getDirectory() + file, txtResult.getText()); } } else if (s.equals("Results in Text")) { iResult = 1; pResult.removeAll(); pResult.add("Center", txtResult); pResult.doLayout(); showResultInText(); } else if (s.equals("AutoCommit on")) { try { cConn.setAutoCommit(true); } catch (SQLException e) { } } else if (s.equals("AutoCommit off")) { try { cConn.setAutoCommit(false); } catch (SQLException e) { } } else if (s.equals("Enlarge Tree")) { Dimension d = tTree.getMinimumSize(); d.width += 20; tTree.setMinimumSize(d); fMain.pack(); } else if (s.equals("Shrink Tree")) { Dimension d = tTree.getMinimumSize(); d.width -= 20; if (d.width >= 0) { tTree.setMinimumSize(d); } fMain.pack(); } else if (s.equals("Enlarge Command")) { txtCommand.setRows(txtCommand.getRows() + 1); fMain.pack(); } else if (s.equals("Shrink Command")) { int i = txtCommand.getRows() - 1; txtCommand.setRows(i < 1 ? 1 : i); fMain.pack(); } else if (s.equals("Commit")) { try { cConn.commit(); } catch (SQLException e) { } } else if (s.equals("Insert test data")) { insertTestData(); } else if (s.equals("Rollback")) { try { cConn.rollback(); } catch (SQLException e) { } } else if (s.equals("Disable MaxRows")) { try { sStatement.setMaxRows(0); } catch (SQLException e) { } } else if (s.equals("Set MaxRows to 100")) { try { sStatement.setMaxRows(100); } catch (SQLException e) { } } else if (s.equals("SELECT")) { showHelp(DatabaseManagerCommon.selectHelp); } else if (s.equals("INSERT")) { showHelp(DatabaseManagerCommon.insertHelp); } else if (s.equals("UPDATE")) { showHelp(DatabaseManagerCommon.updateHelp); } else if (s.equals("DELETE")) { showHelp(DatabaseManagerCommon.deleteHelp); } else if (s.equals("CREATE TABLE")) { showHelp(DatabaseManagerCommon.createTableHelp); } else if (s.equals("DROP TABLE")) { showHelp(DatabaseManagerCommon.dropTableHelp); } else if (s.equals("CREATE INDEX")) { showHelp(DatabaseManagerCommon.createIndexHelp); } else if (s.equals("DROP INDEX")) { showHelp(DatabaseManagerCommon.dropIndexHelp); } else if (s.equals("CHECKPOINT")) { showHelp(DatabaseManagerCommon.checkpointHelp); } else if (s.equals("SCRIPT")) { showHelp(DatabaseManagerCommon.scriptHelp); } else if (s.equals("SHUTDOWN")) { showHelp(DatabaseManagerCommon.shutdownHelp); } else if (s.equals("SET")) { showHelp(DatabaseManagerCommon.setHelp); } else if (s.equals("Test Script")) { showHelp(DatabaseManagerCommon.testHelp); } }
public void actionPerformed(ActionEvent e) { atc_obj.getInputhandler().processActionCommand(e.getActionCommand()); }
public void actionPerformed(ActionEvent e) { String arg = (String) e.getActionCommand(); /** ******************** Open an Image **************** */ if (e.getSource() == m_Open) { int returnVal = jfc.showOpenDialog(IPToolKit.this); if (returnVal == JFileChooser.APPROVE_OPTION) { file = jfc.getSelectedFile(); String path = file.getAbsolutePath(); // image = Toolkit.getDefaultToolkit().getImage(path); try { try { inImage = new FileImageInputStream(file); len = (int) inImage.length(); byteArray = new byte[len]; // System.out.println(len); inImage.read(byteArray, 0, len); image = Toolkit.getDefaultToolkit().createImage(byteArray); MediaTracker t = new MediaTracker(this); t.addImage(image, 0); try { t.waitForID(0); } catch (Exception eeee) { System.out.println(eeee); } w = image.getWidth(null); h = image.getHeight(null); // System.out.println(w+"\t"+h); } catch (Exception fnfe) { JOptionPane.showMessageDialog(this, "File: Not Found"); } } catch (Exception ice) { JOptionPane.showMessageDialog(this, "File I/O Error"); } } if (image != null) { pix_temp = new int[h * w]; ImageIcon icon = new ImageIcon(image); lbl_img.setIcon(icon); setVisible(true); } pix_temp = pixel_grab(image, w, h); pix_temp = pix_pack(pix_temp, w, h); grayImageDisplay(w, h, pix_temp); } /** ****************** Add one image to another ************** */ if (e.getSource() == mAddImg) { OpenImage2(); pix_temp1 = new int[w * h]; pix_res = new int[w * h]; pix_temp1 = pixel_grab(image1, w1, h1); pix_temp1 = pix_pack(pix_temp1, w1, h1); for (int s = 0; s < w * h; s++) { pix_res[s] = pix_temp[s] + pix_temp1[s]; } ; pix_temp1 = saturate(pix_temp1, w, h); imageResultDisplay(w, h, pix_res); } /** * *********************** Add Constant value and then use Satuartion technique *************** */ if (e.getSource() == mAddSat) { String add_value; Image img_add = image; pixel_add = new int[w * h]; pixel_result = pixel_grab(img_add, w, h); add_value = JOptionPane.showInputDialog("Enter Value you wish to add to the image"); int number = Integer.parseInt(add_value); for (int r = 0; r < w * h; r++) { pixel_add[r] = number + pixel_result[r]; } pixel_add = saturate(pixel_add, w, h); pixel_add = pix_pack(pixel_add, w, h); imageResultDisplay(w, h, pixel_add); } /** ************ Add constant by Wrap Around technique ********** */ if (e.getSource() == mAddWrap) { String add_value; Image img_add = image; pixel_add = new int[w * h]; pixel_result = pixel_grab(img_add, w, h); add_value = JOptionPane.showInputDialog("Enter Value you wish to add to the image"); int number = Integer.parseInt(add_value); for (int r = 0; r < w * h; r++) { pixel_add[r] = number + pixel_result[r]; } pixel_add = WrapAround(pixel_add, w, h); pixel_add = pix_pack(pixel_add, w, h); imageResultDisplay(w, h, pixel_add); } /** ****************** Subtract one image from another ************** */ if (e.getSource() == mSubImg) { OpenImage2(); pix_temp1 = new int[w * h]; pix_res = new int[w * h]; pix_temp1 = pixel_grab(image1, w1, h1); pix_temp1 = pix_pack(pix_temp1, w1, h1); for (int s = 0; s < w * h; s++) { pix_res[s] = pix_temp[s] - pix_temp1[s]; } pix_temp1 = saturate(pix_temp1, w1, h1); imageResultDisplay(w1, h1, pix_res); } /** * *********************** Subtract Constant value and then use Satuartion technique * *************** */ if (e.getSource() == mSubSat) { String sub_value; Image img_add = image; pixel_sub = new int[w * h]; pixel_result = pixel_grab(img_add, w, h); sub_value = JOptionPane.showInputDialog("Enter Value you wish to subtract from the image"); int number = Integer.parseInt(sub_value); for (int r = 0; r < w * h; r++) { pixel_sub[r] = pixel_result[r] - number; } pixel_sub = saturate(pixel_sub, w, h); pixel_sub = pix_pack(pixel_sub, w, h); imageResultDisplay(w, h, pixel_sub); } /** ************ Subtract constant by Wrap Around technique ********** */ if (e.getSource() == mSubWrap) { String sub_value; Image img_add = image; pixel_sub = new int[w * h]; pixel_result = pixel_grab(img_add, w, h); sub_value = JOptionPane.showInputDialog("Enter Value you wish to add to the image"); int number = Integer.parseInt(sub_value); for (int r = 0; r < w * h; r++) { pixel_sub[r] = pixel_result[r] - number; } pixel_sub = WrapAround(pixel_sub, w, h); pixel_sub = pix_pack(pixel_sub, w, h); imageResultDisplay(w, h, pixel_sub); } /** ****************** Multiply one image with another ************** */ if (e.getSource() == mMulImg) { OpenImage2(); pix_temp1 = new int[w * h]; pix_res = new int[w * h]; pix_temp1 = pixel_grab(image1, w1, h1); pix_temp1 = pix_pack(pix_temp1, w1, h1); for (int s = 0; s < w * h; s++) { pix_res[s] = pix_temp[s] * pix_temp1[s]; } pix_temp1 = saturate(pix_temp1, w1, h1); imageResultDisplay(w1, h1, pix_res); } /** * *********************** Multiply Constant value and then use Satuartion technique * *************** */ if (e.getSource() == mMulSat) { String mul_value; Image img_mul = image; pixel_mul = new int[w * h]; pixel_result = pixel_grab(img_mul, w, h); mul_value = JOptionPane.showInputDialog("Enter Value you wish to multiply to the image"); int number = Integer.parseInt(mul_value); for (int r = 0; r < w * h; r++) { pixel_mul[r] = pixel_result[r] * number; } pixel_mul = saturate(pixel_mul, w, h); pixel_mul = pix_pack(pixel_mul, w, h); imageResultDisplay(w, h, pixel_mul); } /** ************ Multiply constant by Wrap Around technique ********** */ if (e.getSource() == mMulWrap) { String mul_value; Image img_mul = image; pixel_mul = new int[w * h]; pixel_result = pixel_grab(img_mul, w, h); mul_value = JOptionPane.showInputDialog("Enter Value you wish to multiply to the image"); int number = Integer.parseInt(mul_value); for (int r = 0; r < w * h; r++) { pixel_mul[r] = pixel_result[r] * number; } pixel_mul = WrapAround(pixel_mul, w, h); pixel_mul = pix_pack(pixel_mul, w, h); imageResultDisplay(w, h, pixel_mul); } /** ****************** Divide one image by another ************** */ if (e.getSource() == mDivImg) { OpenImage2(); pix_temp1 = new int[w * h]; pix_res = new int[w * h]; pix_temp1 = pixel_grab(image1, w1, h1); pix_temp1 = pix_pack(pix_temp1, w1, h1); for (int s = 0; s < w * h; s++) { pix_res[s] = pix_temp1[s] / pix_temp[s]; } // pix_temp1 = saturate(pix_temp1,w1,h1); pix_temp1 = WrapAround(pix_temp1, w, h); imageResultDisplay(w1, h1, pix_res); } /** * *********************** Divide by Constant value and then use Saturation technique * *************** */ if (e.getSource() == mDivSat) { String div_value; Image img_add = image; pixel_div = new int[w * h]; pixel_result = pixel_grab(img_add, w, h); div_value = JOptionPane.showInputDialog("Enter value to divide the image by"); int number = Integer.parseInt(div_value); for (int r = 0; r < w * h; r++) { pixel_div[r] = pixel_result[r] / number; } pixel_div = saturate(pixel_div, w, h); pixel_div = pix_pack(pixel_div, w, h); imageResultDisplay(w, h, pixel_div); } /** ************ Divide constant by Wrap Around technique ********** */ if (e.getSource() == mDivWrap) { String div_value; Image img_add = image; pixel_div = new int[w * h]; pixel_result = pixel_grab(img_add, w, h); div_value = JOptionPane.showInputDialog("Enter value to divide image by"); int number = Integer.parseInt(div_value); for (int r = 0; r < w * h; r++) { pixel_div[r] = pixel_result[r] / number; } pixel_div = WrapAround(pixel_div, w, h); pixel_div = pix_pack(pixel_div, w, h); imageResultDisplay(w, h, pixel_div); } /** ******************** Thresholding ************* */ if (e.getSource() == mThreshold) { String thresh_value; Image img_add = image; pixel_result = pixel_grab(img_add, w, h); thresh_value = JOptionPane.showInputDialog("Enter value to threshold the image"); int number = Integer.parseInt(thresh_value); for (int r = 0; r < w * h; r++) { if (pixel_result[r] >= number) pixel_result[r] = 255; else if (pixel_result[r] <= number) pixel_result[r] = 0; } pixel_result = pix_pack(pixel_result, w, h); imageResultDisplay(w, h, pixel_result); } if (e.getSource() == m_Save) { FileImageOutputStream src_img; int returnVal = jfc.showSaveDialog(IPToolKit.this); if (returnVal == JFileChooser.APPROVE_OPTION) { File fileR = jfc.getSelectedFile(); String fileToSave = file.getAbsolutePath(); if (!fileToSave.toLowerCase().endsWith(".jpg")) { fileR = new File(fileToSave + ".jpg"); } try { src_img = new FileImageOutputStream(fileR); buf_img = getImageFromArray(pixel_result, w, h); ImageIO.write(buf_img, "jpg", src_img); } catch (IOException ex8) { System.out.println(ex8); } } // } } /** ***************************** Increase brightness **************** */ if (e.getSource() == mBright) { String bright_value; Image img_add = image; pixel_result = pixel_grab(img_add, w, h); bright_value = JOptionPane.showInputDialog("Enter value to increase brightness"); int number = Integer.parseInt(bright_value); for (int r = 0; r < w * h; r++) { pixel_result[r] = pixel_result[r] + number; } pixel_result = saturate(pixel_result, w, h); pixel_result = pix_pack(pixel_result, w, h); imageResultDisplay(w, h, pixel_result); } /** ****************** Contrast Strtching *************** */ if (e.getSource() == mContrast) { String cont_value1, cont_value2; Image img_add = image; pixel_cont = new int[w * h]; pixel_result = pixel_grab(img_add, w, h); cont_value1 = JOptionPane.showInputDialog("Enter lower limit for contrast stretch"); int number = Integer.parseInt(cont_value1); cont_value2 = JOptionPane.showInputDialog("Enter higher limit for contrast stretch"); int number1 = Integer.parseInt(cont_value2); for (int r = 0; r < w * h; r++) { if (pixel_result[r] <= number1) { pixel_cont[r] = pixel_result[r] - 50; if (pixel_cont[r] < 0) pixel_cont[r] = 0; } else if (pixel_result[r] >= number) { pixel_cont[r] = pixel_result[r] + 50; if (pixel_cont[r] > 255) pixel_cont[r] = 255; } else pixel_cont[r] = pixel_result[r]; } pixel_cont = saturate(pixel_cont, w, h); pixel_cont = pix_pack(pixel_cont, w, h); imageResultDisplay(w, h, pixel_cont); } /** ******************* Low Pass Filter ****************** */ if (e.getSource() == mlowPass) { int mask[][] = {{1, 1, 1}, {1, 1, 1}, {1, 1, 1}}; pixel_result = pixel_grab(image, w, h); int pix_tempLow[][] = new int[h][w]; pix_tempLow = OneD_ArrayToTwoD_Array(w, h, pixel_result); pix_tempLow = MaskOperation(w, h, pix_tempLow, mask); int pix_temp1D[] = new int[(w) * (h)]; pix_temp1D = TwoD_ArrayToOneD_Array(w, h, pix_tempLow); pix_temp1D = restrict(pix_temp1D); pix_temp1D = pix_pack(pix_temp1D, w - 2, h - 2); imageResultDisplay(w - 2, h - 2, pix_temp1D); } /** ********************* High Pass Filter *************** */ if (e.getSource() == mhighPass) { int mask[][] = {{-1, -1, -1}, {-1, 8, -1}, {-1, -1, -1}}; pixel_result = pixel_grab(image, w, h); int pix_tempLow[][] = new int[h][w]; pix_tempLow = OneD_ArrayToTwoD_Array(w, h, pixel_result); pix_tempLow = MaskOperation(w, h, pix_tempLow, mask); int pix_temp1D[] = new int[(w) * (h)]; pix_temp1D = TwoD_ArrayToOneD_Array(w, h, pix_tempLow); pix_temp1D = saturate(pix_temp1D, w - 2, h - 2); pix_temp1D = restrict(pix_temp1D); pix_temp1D = pix_pack(pix_temp1D, w - 2, h - 2); imageResultDisplay(w - 2, h - 2, pix_temp1D); } /** *************************** High Boost Filter **************** */ if (e.getSource() == mhighBoost) { int mask[][] = {{-1, -1, -1}, {-1, 9, -1}, {-1, -1, -1}}; pixel_result = pixel_grab(image, w, h); int pix_tempLow[][] = new int[h][w]; pix_tempLow = OneD_ArrayToTwoD_Array(w, h, pixel_result); pix_tempLow = MaskOperation(w, h, pix_tempLow, mask); int pix_temp1D[] = new int[(w) * (h)]; pix_temp1D = TwoD_ArrayToOneD_Array(w, h, pix_tempLow); pix_temp1D = saturate(pix_temp1D, w - 2, h - 2); pix_temp1D = restrict(pix_temp1D); pix_temp1D = pix_pack(pix_temp1D, w - 2, h - 2); imageResultDisplay(w - 2, h - 2, pix_temp1D); } if (e.getSource() == m_Save) { for (int i = 0; i < w * h; i++) { System.out.println(pixel_result[i]); } FileImageOutputStream src_img; int returnVal = jfc.showSaveDialog(IPToolKit.this); if (returnVal == JFileChooser.APPROVE_OPTION) { File fileR = jfc.getSelectedFile(); String fileToSave = file.getAbsolutePath(); if (!fileToSave.toLowerCase().endsWith(".jpg")) { fileR = new File(fileToSave + ".jpg"); } try { src_img = new FileImageOutputStream(fileR); buf_img = getImageFromArray(pixel_result, w, h); ImageIO.write(buf_img, "jpg", src_img); } catch (IOException ex8) { System.out.println(ex8); } } } /** ********************* Invert and image ************ */ if (e.getSource() == mInvert) { Image img_Invert = image; pixel_result = new int[w * h]; pixel_result = pixel_grab(img_Invert, w, h); for (int r = 0; r < w * h; r++) { pixel_result[r] = 255 - pixel_result[r]; } // pixel_div = saturate(pixel_div,w,h); pixel_result = pix_pack(pixel_result, w, h); imageResultDisplay(w, h, pixel_result); } /** *************************** Median Filter **************** */ if (arg.equals("Median")) { int[] pix_grabed = new int[w * h]; int[][] p2d = new int[h][w]; int[][] pp2d = new int[h][w]; int pix_pcked[] = new int[w * h]; int pres[] = new int[h * w]; pix_grabed = pixel_grab(image, w, h); p2d = OneD_ArrayToTwoD_Array(w, h, pix_grabed); pp2d = median_filter(p2d); pres = TwoD_ArrayToOneD_Array(w, h, pp2d); pix_pcked = pix_pack(pres, w - 2, h - 2); imageResultDisplay(w - 2, h - 2, pix_pcked); } /** ********************** Prewits Horizontal Edge Detection ******************* */ if (arg.equals("Prewits Horizontal")) { int[] pix_grabed = new int[w * h]; int[][] p2d = new int[h][w]; int[][] pp2d = new int[h][w]; int pix_pcked[] = new int[w * h]; int pres[] = new int[h * w]; int mask[][] = {{-1, -1, -1}, {0, 0, 0}, {1, 1, 1}}; pix_grabed = pixel_grab(image, w, h); p2d = OneD_ArrayToTwoD_Array(w, h, pix_grabed); pp2d = MaskOperation(w, h, p2d, mask); pres = TwoD_ArrayToOneD_Array(w, h, pp2d); pres = saturate(pres, w - 2, h - 2); pres = restrict(pres); pix_pcked = pix_pack(pres, w - 2, h - 2); imageResultDisplay(w - 2, h - 2, pix_pcked); } /** ********************** Prewits Vertical Edge Detection ******************* */ if (arg.equals("Prewits Vertical")) { int[] pix_grabed = new int[w * h]; int[][] p2d = new int[h][w]; int[][] pp2d = new int[h][w]; int pix_pcked[] = new int[w * h]; int pres[] = new int[h * w]; int mask[][] = {{-1, 0, 1}, {-1, 0, 1}, {-1, 0, 1}}; pix_grabed = pixel_grab(image, w, h); p2d = OneD_ArrayToTwoD_Array(w, h, pix_grabed); pp2d = MaskOperation(w, h, p2d, mask); pres = TwoD_ArrayToOneD_Array(w, h, pp2d); pres = saturate(pres, w - 2, h - 2); pres = restrict(pres); pix_pcked = pix_pack(pres, w - 2, h - 2); imageResultDisplay(w - 2, h - 2, pix_pcked); } /** ********************** Prewits Edge Detection ******************* */ if (arg.equals("Prewits Both")) { int[] pix_grabed = new int[w * h]; int[][] p2d = new int[h][w]; int[][] pp2d = new int[h][w]; int pix_pcked[] = new int[w * h]; int pres1[] = new int[h * w]; int pres2[] = new int[h * w]; int pres[] = new int[h * w]; int mask1[][] = {{-1, -1, -1}, {0, 0, 0}, {1, 1, 1}}; pix_grabed = pixel_grab(image, w, h); p2d = OneD_ArrayToTwoD_Array(w, h, pix_grabed); pp2d = MaskOperation(w, h, p2d, mask1); pres1 = TwoD_ArrayToOneD_Array(w, h, pp2d); pres1 = saturate(pres1, w - 2, h - 2); pres1 = restrict(pres1); int mask2[][] = {{-1, 0, 1}, {-1, 0, 1}, {-1, 0, 1}}; p2d = OneD_ArrayToTwoD_Array(w, h, pix_grabed); pp2d = MaskOperation(w, h, p2d, mask2); pres2 = TwoD_ArrayToOneD_Array(w, h, pp2d); pres2 = saturate(pres2, w - 2, h - 2); pres2 = restrict(pres2); for (int i = 0; i < ((h - 2) * (w - 2)); i++) { pres[i] = pres1[i] + pres2[i]; } pix_pcked = pix_pack(pres, w - 2, h - 2); imageResultDisplay(w - 2, h - 2, pix_pcked); } /** ********************** Sobel Horizontal Edge Detection ******************* */ if (arg.equals("Sobel Horizontal")) { int[] pix_grabed = new int[w * h]; int[][] p2d = new int[h][w]; int[][] pp2d = new int[h][w]; int pix_pcked[] = new int[w * h]; int pres[] = new int[h * w]; int mask[][] = {{-1, -2, -1}, {0, 0, 0}, {1, 2, 1}}; pix_grabed = pixel_grab(image, w, h); p2d = OneD_ArrayToTwoD_Array(w, h, pix_grabed); pp2d = MaskOperation(w, h, p2d, mask); pres = TwoD_ArrayToOneD_Array(w, h, pp2d); pres = saturate(pres, w - 2, h - 2); pres = restrict(pres); pix_pcked = pix_pack(pres, w - 2, h - 2); imageResultDisplay(w - 2, h - 2, pix_pcked); } /** ********************** Sobel Vertical Edge Detection ******************* */ if (arg.equals("Sobel Vertical")) { int[] pix_grabed = new int[w * h]; int[][] p2d = new int[h][w]; int[][] pp2d = new int[h][w]; int pix_pcked[] = new int[w * h]; int pres[] = new int[h * w]; int mask[][] = {{-1, 0, 1}, {-2, 0, 2}, {-1, 0, 1}}; pix_grabed = pixel_grab(image, w, h); p2d = OneD_ArrayToTwoD_Array(w, h, pix_grabed); pp2d = MaskOperation(w, h, p2d, mask); pres = TwoD_ArrayToOneD_Array(w, h, pp2d); pres = saturate(pres, w - 2, h - 2); pres = restrict(pres); pix_pcked = pix_pack(pres, w - 2, h - 2); imageResultDisplay(w - 2, h - 2, pix_pcked); } /** ********************** Sobel Edge Detection ******************* */ if (arg.equals("Sobel Both")) { int[] pix_grabed = new int[w * h]; int[][] p2d = new int[h][w]; int[][] pp2d = new int[h][w]; int pix_pcked[] = new int[w * h]; int pres1[] = new int[h * w]; int pres2[] = new int[h * w]; int pres[] = new int[h * w]; int mask1[][] = {{-1, -2, -1}, {0, 0, 0}, {1, 2, 1}}; pix_grabed = pixel_grab(image, w, h); p2d = OneD_ArrayToTwoD_Array(w, h, pix_grabed); pp2d = MaskOperation(w, h, p2d, mask1); pres1 = TwoD_ArrayToOneD_Array(w, h, pp2d); pres1 = saturate(pres1, w - 2, h - 2); pres1 = restrict(pres1); int mask2[][] = {{-1, 0, 1}, {-2, 0, 2}, {-1, 0, 1}}; p2d = OneD_ArrayToTwoD_Array(w, h, pix_grabed); pp2d = MaskOperation(w, h, p2d, mask2); pres2 = TwoD_ArrayToOneD_Array(w, h, pp2d); pres2 = saturate(pres2, w - 2, h - 2); pres2 = restrict(pres2); for (int i = 0; i < ((h - 2) * (w - 2)); i++) { pres[i] = pres1[i] + pres2[i]; } pix_pcked = pix_pack(pres, w - 2, h - 2); imageResultDisplay(w - 2, h - 2, pix_pcked); } /** ********************** Roberts Edge Detection ******************* */ if (arg.equals("Roberts")) { int[] pix_grabed = new int[w * h]; int[][] p2d = new int[h][w]; int[][] pp2d = new int[h][w]; int pix_pcked[] = new int[w * h]; int pres[] = new int[h * w]; int mask[][] = {{1, 0}, {0, -1}}; pix_grabed = pixel_grab(image, w, h); p2d = OneD_ArrayToTwoD_Array(w, h, pix_grabed); for (int i = 1; i < h - 1; i++) { for (int j = 1; j < w - 1; j++) { pp2d[i][j] = ((mask[0][0] * p2d[i - 1][j - 1] + mask[1][0] * p2d[i + 1][j - 1]) + (mask[0][1] * p2d[i - 1][j + 1] + mask[1][1] * p2d[i + 1][j + 1])) / 2; } } pres = TwoD_ArrayToOneD_Array(w, h, pp2d); pres = saturate(pres, w - 2, h - 2); pix_pcked = pix_pack(pres, w - 2, h - 2); imageResultDisplay(w - 2, h - 2, pix_pcked); } /** ********************** Mean Filter ******************* */ if (arg.equals("Mean")) { int[] pix_grabed = new int[w * h]; int[][] p2d = new int[h][w]; int[][] pp2d = new int[h][w]; int pix_pcked[] = new int[w * h]; int pres[] = new int[h * w]; pix_grabed = pixel_grab(image, w, h); p2d = OneD_ArrayToTwoD_Array(w, h, pix_grabed); pp2d = mean_filt(p2d); pres = TwoD_ArrayToOneD_Array(w, h, pp2d); pix_pcked = pix_pack(pres, w - 2, h - 2); imageResultDisplay(w - 2, h - 2, pix_pcked); } /** ********************** Laplacian Edge Detector ******************* */ if (arg.equals("Laplacian")) { int[] pix_grabed = new int[w * h]; int[][] p2d = new int[h][w]; int[][] pp2d = new int[h][w]; int pix_pcked[] = new int[w * h]; int pres[] = new int[h * w]; int mask[][] = {{0, -2, 0}, {-2, 8, -2}, {0, -2, 0}}; pix_grabed = pixel_grab(image, w, h); p2d = OneD_ArrayToTwoD_Array(w, h, pix_grabed); pp2d = MaskOperation(w, h, p2d, mask); pres = TwoD_ArrayToOneD_Array(w, h, pp2d); pres = saturate(pres, w - 2, h - 2); pres = restrict(pres); pix_pcked = pix_pack(pres, w - 2, h - 2); imageResultDisplay(w - 2, h - 2, pix_pcked); } /** ********************** Histogram Equalization ******************* */ if (arg.equals("Histogram Equalization")) { int[] pix_grabed = new int[h * w]; int pres[] = new int[h * w]; int cnt_pix[] = new int[256]; int pixx[] = new int[h * w]; int pix_pcked[] = new int[h * w]; int pix_res[] = new int[h * w]; int len = h * w; int res = 0; pix_grabed = pixel_grab(image, w, h); for (int i = 0; i < h * w; i++) { pixx[i] = pix_grabed[i]; } for (int i = 0; i < 256; i++) { cnt_pix[i] = 0; } for (int i = 0; i < len; i++) { int ind = pixx[i]; cnt_pix[ind]++; } for (int i = 0; i < w * h; i++) { float a = 0; for (int j = 0; j < (pixx[i] + 1); j++) { float b = (float) cnt_pix[j]; float c = (float) (h * w); a = a + (b / c); } res = (int) (a * 255); if (res > 255) res = 255; pix_res[i] = (0xff000000 | (res << 16) | (res << 8) | res); } pix_pcked = pix_pack(pix_res, w, h); imageResultDisplay(w, h, pix_pcked); } if (arg.equals("Connected Component")) { int pix_grabed[] = new int[h * w]; int p2d[][] = new int[h][w]; conect_input = new int[h][w]; conect_output = new int[h][w]; int x1 = x_cor; int y1 = y_cor; pix_grabed = pixel_grab(image, w, h); p2d = OneD_ArrayToTwoD_Array(w, h, pix_grabed); s = 0; t = 0; obj_size = 0; intensity = p2d[y1][x1]; for (int i = 0; i < h; i++) { for (int j = 0; j < w; j++) { conect_input[i][j] = p2d[i][j]; conect_output[i][j] = 0; } } connect(y1, x1); int pixx[] = new int[h * w]; int pp[] = new int[h * w]; pixx = TwoD_ArrayToOneD_Array(w, h, conect_output); pixx = saturate(pixx, w - 2, h - 2); pp = pix_pack(pixx, w - 2, h - 2); imageResultDisplay(w - 2, h - 2, pp); } /** ********************** Blending ******************* */ if (arg.equals("Blending")) { int size; int hei, wid; if (h1 > h) hei = h1; else hei = h; if (w1 > w) wid = w1; else wid = w; size = hei * wid; int pix_img1[] = new int[size]; int pix_img2[] = new int[size]; int pix_res[] = new int[size]; int pixx[] = new int[h1 * w1]; double x = 0.5; pix_img1 = pixel_grab(image, w, h); OpenImage2(); pix_img2 = pixel_grab(image1, w1, h1); // grayImageDisplay(w1,h1,pixx) for (int i = 0; i < size; i++) { pix_res[i] = (int) ((x * pix_img1[i]) + ((1 - x) * (pix_img2[i]))); } int pix_pcked[] = new int[size]; pix_pcked = pix_pack(pix_res, wid, hei); imageResultDisplay(wid, hei, pix_pcked); } /** ****************** Quit OR Exit **************** */ if (arg.equals("Exit")) { System.exit(0); } }
public void actionPerformed(ActionEvent ev) { String s = ev.getActionCommand(); if (s == null) { if (ev.getSource() instanceof JMenuItem) { JMenuItem i; s = ((JMenuItem) ev.getSource()).getText(); } } /* // button replace by toolbar if (s.equals("Execute")) { execute(); } else */ if (s.equals("Exit")) { windowClosing(null); } else if (s.equals("Transfer")) { Transfer.work(null); } else if (s.equals("Dump")) { Transfer.work(new String[] {"-d"}); } else if (s.equals("Restore")) { Transfer.work(new String[] {"-r"}); } else if (s.equals("Logging on")) { javaSystem.setLogToSystem(true); } else if (s.equals("Logging off")) { javaSystem.setLogToSystem(false); } else if (s.equals("Refresh Tree")) { refreshTree(); } else if (s.startsWith("#")) { int i = Integer.parseInt(s.substring(1)); txtCommand.setText(sRecent[i]); } else if (s.equals("Connect...")) { connect(ConnectionDialogSwing.createConnection(fMain, "Connect")); refreshTree(); } else if (s.equals("Results in Grid")) { iResult = 0; pResult.removeAll(); pResult.add(gScrollPane, BorderLayout.CENTER); pResult.doLayout(); gResult.fireTableChanged(null); pResult.repaint(); } else if (s.equals("Open Script...")) { JFileChooser f = new JFileChooser("."); f.setDialogTitle("Open Script..."); // (ulrivo): set default directory if set from command line if (defDirectory != null) { f.setCurrentDirectory(new File(defDirectory)); } int option = f.showOpenDialog(fMain); if (option == JFileChooser.APPROVE_OPTION) { File file = f.getSelectedFile(); if (file != null) { StringBuffer buf = new StringBuffer(); ifHuge = DatabaseManagerCommon.readFile(file.getAbsolutePath()); if (4096 <= ifHuge.length()) { buf.append("This huge file cannot be edited. Please execute\n"); txtCommand.setText(buf.toString()); } else { txtCommand.setText(ifHuge); } } } } else if (s.equals("Save Script...")) { JFileChooser f = new JFileChooser("."); f.setDialogTitle("Save Script"); // (ulrivo): set default directory if set from command line if (defDirectory != null) { f.setCurrentDirectory(new File(defDirectory)); } int option = f.showSaveDialog(fMain); if (option == JFileChooser.APPROVE_OPTION) { File file = f.getSelectedFile(); if (file != null) { DatabaseManagerCommon.writeFile(file.getAbsolutePath(), txtCommand.getText()); } } } else if (s.equals("Save Result...")) { JFileChooser f = new JFileChooser("."); f.setDialogTitle("Save Result..."); // (ulrivo): set default directory if set from command line if (defDirectory != null) { f.setCurrentDirectory(new File(defDirectory)); } int option = f.showSaveDialog(fMain); if (option == JFileChooser.APPROVE_OPTION) { File file = f.getSelectedFile(); if (file != null) { showResultInText(); DatabaseManagerCommon.writeFile(file.getAbsolutePath(), txtResult.getText()); } } } else if (s.equals("Results in Text")) { iResult = 1; pResult.removeAll(); pResult.add(txtResultScroll, BorderLayout.CENTER); pResult.doLayout(); showResultInText(); pResult.repaint(); } else if (s.equals("AutoCommit on")) { try { cConn.setAutoCommit(true); } catch (SQLException e) { } } else if (s.equals("AutoCommit off")) { try { cConn.setAutoCommit(false); } catch (SQLException e) { } } else if (s.equals("Commit")) { try { cConn.commit(); } catch (SQLException e) { } } else if (s.equals("Insert test data")) { insertTestData(); } else if (s.equals("Rollback")) { try { cConn.rollback(); } catch (SQLException e) { } } else if (s.equals("Disable MaxRows")) { try { sStatement.setMaxRows(0); } catch (SQLException e) { } } else if (s.equals("Set MaxRows to 100")) { try { sStatement.setMaxRows(100); } catch (SQLException e) { } } else if (s.equals("SELECT")) { showHelp(DatabaseManagerCommon.selectHelp); } else if (s.equals("INSERT")) { showHelp(DatabaseManagerCommon.insertHelp); } else if (s.equals("UPDATE")) { showHelp(DatabaseManagerCommon.updateHelp); } else if (s.equals("DELETE")) { showHelp(DatabaseManagerCommon.deleteHelp); } else if (s.equals("CREATE TABLE")) { showHelp(DatabaseManagerCommon.createTableHelp); } else if (s.equals("DROP TABLE")) { showHelp(DatabaseManagerCommon.dropTableHelp); } else if (s.equals("CREATE INDEX")) { showHelp(DatabaseManagerCommon.createIndexHelp); } else if (s.equals("DROP INDEX")) { showHelp(DatabaseManagerCommon.dropIndexHelp); } else if (s.equals("CHECKPOINT")) { showHelp(DatabaseManagerCommon.checkpointHelp); } else if (s.equals("SCRIPT")) { showHelp(DatabaseManagerCommon.scriptHelp); } else if (s.equals("SHUTDOWN")) { showHelp(DatabaseManagerCommon.shutdownHelp); } else if (s.equals("SET")) { showHelp(DatabaseManagerCommon.setHelp); } else if (s.equals("Test Script")) { showHelp(DatabaseManagerCommon.testHelp); } }