public static void Field1(){ fieldT.Label(); fieldT.panel(); f1.setSize(400, 400); Dimension screen = Toolkit.getDefaultToolkit().getScreenSize(); // 화면 픽셀 계산 Dimension frm = f1.getSize();//창 크기 계산 int xpos = (int)(screen.getWidth() / 2 - frm.getWidth() / 2); // 창 중앙 위치 계산 int ypos = (int)(screen.getHeight() / 2 - frm.getHeight() / 2); f1.setLayout(new GridLayout(4, 4));// 프레임 레이아웃 f1.setBackground(Color.cyan); //프레임 배경 f1.addWindowListener(new WEventHandler()); f1.addKeyListener(new KEventHandler()); f1.setResizable(false); for(int i =0;i<4;i++){ for(int j=0;j<4;j++){ f1.add(p[i][j]); } } f1.setLocation(xpos, ypos); f1.setVisible(true); }
public static void main(String[] args) { Frame frame = new Frame("Tetris"); Tetris tetris = new Tetris(); frame.add(tetris); tetris.init(); tetris.start(); frame.addWindowListener( new WindowAdapter() { public void windowClosing(WindowEvent e) { System.exit(0); } }); frame.setSize(489, 441); frame.setResizable(false); frame.setVisible(true); }
public static void main(String[] args) { final GLCanvas canvas = new GLCanvas(); final Frame frame = new Frame("Jogl Quad drawing"); final Animator animator = new Animator(canvas); canvas.addGLEventListener(new Test()); frame.add(canvas); frame.setSize(640, 480); frame.setResizable(false); frame.addWindowListener( new WindowAdapter() { public void windowClosing(WindowEvent e) { animator.stop(); frame.dispose(); System.exit(0); } }); frame.setVisible(true); animator.start(); canvas.requestFocus(); }
void init() { mainFrame = new Frame(); mainFrame.setBounds(400, 500, 800, 600); mainFrame.setLayout(new FlowLayout()); mainFrame.setResizable(false); upPanel = new Panel(); downPanel = new Panel(); addressTextField = new TextField(75); gotoButton = new Button("转到"); contentTextArea = new TextArea(30, 82); upPanel.add(addressTextField); upPanel.add(gotoButton); downPanel.add(contentTextArea); mainFrame.add(upPanel); mainFrame.add(downPanel); addEvent(); mainFrame.setVisible(true); }
public void run(String arg) { GenericDialog gd = new GenericDialog("Options"); double sfreq = 20000.0; gd.addNumericField("Sampling Frequency?", sfreq, 1, 10, null); String[] psfchoice = {"3D Gaussian", "Gaus-Lorentz^2", "2D Gaussian"}; gd.addChoice("PSF Type?", psfchoice, psfchoice[0]); String[] filetypechoice = { "Confocor 3 raw", "Short binary trajectory", "PlotWindow trajectory", "Ascii Text File" }; gd.addChoice("File Type?", filetypechoice, filetypechoice[0]); boolean ch2green = true; gd.addCheckbox("Ch2 is green?", ch2green); gd.showDialog(); if (gd.wasCanceled()) { return; } sfreq = gd.getNextNumber(); int psfflag = gd.getNextChoiceIndex(); int fileflag = gd.getNextChoiceIndex(); ch2green = gd.getNextBoolean(); int nfiles = 0; Object[] histograms = null; int xmax = 0; int ymax = 0; String[] names = null; if (fileflag < 2) { jdataio ioclass = new jdataio(); File[] filearray = ioclass.openfiles(OpenDialog.getDefaultDirectory(), IJ.getInstance()); if (filearray.length == 0) { return; } String dir = filearray[0].getAbsolutePath(); int sepindex = dir.lastIndexOf(File.separator); String newdir = dir.substring(0, sepindex + 1); OpenDialog.setDefaultDirectory(newdir); nfiles = filearray.length / 2; if (nfiles > 25) { nfiles = 25; } histograms = new Object[nfiles]; names = organize_c3_files(filearray); for (int i = 0; i < nfiles; i++) { try { int length1 = (int) (((double) filearray[2 * i].length() - 128.0) / 4.0); int length2 = (int) (((double) filearray[2 * i + 1].length() - 128.0) / 4.0); int length3 = (int) (((double) filearray[2 * i].length()) / 2.0); int length4 = (int) (((double) filearray[2 * i + 1].length()) / 2.0); InputStream instream = new BufferedInputStream(new FileInputStream(filearray[2 * i])); InputStream instream2 = new BufferedInputStream(new FileInputStream(filearray[2 * i + 1])); if (fileflag == 0) { int[] pmdata = new int[length1]; int[] pmdata2 = new int[length2]; if (!ioclass.skipstreambytes(instream, 128)) { showioerror(); instream.close(); return; } if (!ioclass.skipstreambytes(instream2, 128)) { showioerror(); instream2.close(); return; } if (!ioclass.readintelintfile(instream, length1, pmdata)) { showioerror(); instream.close(); return; } if (!ioclass.readintelintfile(instream2, length2, pmdata2)) { showioerror(); instream2.close(); return; } if (ch2green) { histograms[i] = (new pmodeconvert()).pm2pch(pmdata2, pmdata, sfreq, 20000000); } else { histograms[i] = (new pmodeconvert()).pm2pch(pmdata, pmdata2, sfreq, 20000000); } } else { float[] tmdata = new float[length3]; float[] tmdata2 = new float[length4]; if (!ioclass.readintelshortfile(instream, length3, tmdata)) { showioerror(); instream.close(); return; } if (!ioclass.readintelshortfile(instream2, length4, tmdata2)) { showioerror(); instream2.close(); return; } if (ch2green) { histograms[i] = (new pmodeconvert()).create_2Dhistogram(tmdata2, tmdata); } else { histograms[i] = (new pmodeconvert()).create_2Dhistogram(tmdata, tmdata2); } } if (((float[][]) histograms[i]).length > xmax) { xmax = ((float[][]) histograms[i]).length; } if (((float[][]) histograms[i])[0].length > ymax) { ymax = ((float[][]) histograms[i])[0].length; } instream.close(); instream2.close(); } catch (IOException e) { showioerror(); return; } } } else { if (fileflag == 2) { ImageWindow iw = WindowManager.getCurrentWindow(); float[][] trajectories = (float[][]) jutils.runPW4VoidMethod(iw, "getYValues"); float[][] tempxvals = (float[][]) jutils.runPW4VoidMethod(iw, "getXValues"); sfreq = 1.0 / ((double) tempxvals[0][1]); nfiles = trajectories.length / 2; if (nfiles > 25) { nfiles = 25; } names = new String[nfiles + 1]; names[nfiles] = "avg"; histograms = new Object[nfiles]; for (int i = 0; i < nfiles; i++) { names[i] = "trajectory " + (i + 1); if (ch2green) { histograms[i] = (new pmodeconvert()) .create_2Dhistogram(trajectories[2 * i + 1], trajectories[2 * i]); } else { histograms[i] = (new pmodeconvert()) .create_2Dhistogram(trajectories[2 * i], trajectories[2 * i + 1]); } if (((float[][]) histograms[i]).length > xmax) { xmax = ((float[][]) histograms[i]).length; } if (((float[][]) histograms[i])[0].length > ymax) { ymax = ((float[][]) histograms[i])[0].length; } } } else { // here we read tab delimited lines from files jdataio ioclass = new jdataio(); File[] filearray = ioclass.openfiles(OpenDialog.getDefaultDirectory(), IJ.getInstance()); if (filearray.length == 0) { return; } String dir = filearray[0].getAbsolutePath(); int sepindex = dir.lastIndexOf(File.separator); String newdir = dir.substring(0, sepindex + 1); OpenDialog.setDefaultDirectory(newdir); nfiles = filearray.length; if (nfiles > 25) { nfiles = 25; } histograms = new Object[nfiles]; names = new String[nfiles + 1]; names[nfiles] = "avg"; for (int i = 0; i < nfiles; i++) { try { names[i] = filearray[i].getName(); BufferedReader d = new BufferedReader(new FileReader(filearray[i])); String[] lines = new String[256]; int counter = 0; do { lines[counter] = d.readLine(); counter++; } while ((lines[counter - 1] != null && lines[counter - 1] != "") && counter < 256); int numcolumns = 0; for (int j = 0; j < counter - 1; j++) { int temp = getncolumns(lines[j]); if (temp > numcolumns) { numcolumns = temp; } } float[][] temphist2 = null; if (ch2green) { temphist2 = new float[numcolumns][counter - 1]; } else { temphist2 = new float[counter - 1][numcolumns]; } for (int k = 0; k < counter - 1; k++) { float[] temp = tab_delim2float(lines[k]); for (int j = 0; j < numcolumns; j++) { if (ch2green) { temphist2[j][k] = temp[j]; } else { temphist2[k][j] = temp[j]; } } } histograms[i] = temphist2; d.close(); } catch (IOException e) { showioerror(); return; } } for (int i = 0; i < nfiles; i++) { if (((float[][]) histograms[i]).length > xmax) { xmax = ((float[][]) histograms[i]).length; } if (((float[][]) histograms[i])[0].length > ymax) { ymax = ((float[][]) histograms[i])[0].length; } } } } // note that here x is green and y is red float[][][] pch = new float[nfiles][xmax][ymax]; for (int i = 0; i < nfiles; i++) { for (int j = 0; j < ((float[][]) histograms[i]).length; j++) { for (int k = 0; k < ((float[][]) histograms[i])[j].length; k++) { pch[i][j][k] = ((float[][]) histograms[i])[j][k]; } } } final PCH2DFitWindow cw = new PCH2DFitWindow(); cw.init(names, pch, psfflag); final Frame f = new Frame("PCH 2D Analysis"); f.setLocation(10, 10); f.addWindowListener( new WindowAdapter() { public void windowClosing(WindowEvent e) { f.dispose(); } }); f.add(cw); f.pack(); f.setResizable(false); Insets ins = f.getInsets(); cw.totalSize.height = PCH2DFitWindow.H + ins.bottom + ins.top + 65; cw.totalSize.width = PCH2DFitWindow.WR + ins.left + ins.right; f.setSize(cw.totalSize); f.setVisible(true); cw.requestFocus(); }
public static void main(String[] args) { cg1Canvas T = new cg1Canvas(300, 300); T.setColor(1.0f, 1.0f, 1.0f); T.clear(); float quad1x[] = new float[4]; float quad1y[] = new float[4]; quad1x[0] = 20; quad1x[1] = 20; quad1x[2] = 40; quad1x[3] = 40; quad1y[0] = 20; quad1y[1] = 40; quad1y[2] = 40; quad1y[3] = 20; float quad2x[] = new float[4]; float quad2y[] = new float[4]; quad2x[0] = 80; quad2x[1] = 80; quad2x[2] = 60; quad2x[3] = 60; quad2y[0] = 60; quad2y[1] = 100; quad2y[2] = 100; quad2y[3] = 60; float quad3x[] = new float[4]; float quad3y[] = new float[4]; quad3x[0] = 20; quad3x[1] = 50; quad3x[2] = 50; quad3x[3] = 20; quad3y[0] = 60; quad3y[1] = 60; quad3y[2] = 50; quad3y[3] = 50; float quad4x[] = new float[4]; float quad4y[] = new float[4]; quad4x[0] = 44; quad4x[1] = 60; quad4x[2] = 60; quad4x[3] = 44; quad4y[0] = 22; quad4y[1] = 22; quad4y[2] = 46; quad4y[3] = 46; float pent1x[] = new float[5]; float pent1y[] = new float[5]; pent1x[0] = 80; pent1x[1] = 90; pent1x[2] = 110; pent1x[3] = 100; pent1x[4] = 80; pent1y[0] = 20; pent1y[1] = 10; pent1y[2] = 20; pent1y[3] = 50; pent1y[4] = 40; float hept1x[] = new float[7]; float hept1y[] = new float[7]; hept1x[0] = 120; hept1x[1] = 140; hept1x[2] = 160; hept1x[3] = 160; hept1x[4] = 140; hept1x[5] = 120; hept1x[6] = 110; hept1y[0] = 70; hept1y[1] = 70; hept1y[2] = 80; hept1y[3] = 100; hept1y[4] = 110; hept1y[5] = 100; hept1y[6] = 90; float wx[] = new float[50]; float wy[] = new float[50]; int wl; /* * first polygon: entirely within region */ wl = 0; wl = T.clipPolygon(4, quad1x, quad1y, wx, wy, 10, 10, 50, 50); T.setColor(1.0f, 0.0f, 0.0f); /* red */ T.printLoop(4, quad1x, quad1y); T.printPoly(wl, wx, wy); /* * second polygon: entirely outside region */ wl = 0; wl = T.clipPolygon(4, quad2x, quad2y, wx, wy, 10, 10, 50, 50); /* shouldn't draw anything! */ if (wl > 0) { T.setColor(0.0f, 1.0f, 0.0f); /* green */ T.printLoop(4, quad2x, quad2y); T.printPoly(wl, wx, wy); } // /* * third polygon: halfway outside on left */ wl = 0; wl = T.clipPolygon(4, quad3x, quad3y, wx, wy, 30, 10, 70, 80); T.setColor(0.0f, 0.0f, 1.0f); /* blue */ T.printLoop(4, quad3x, quad3y); T.printPoly(wl, wx, wy); /* * fourth polygon: part outside on right */ wl = 0; wl = T.clipPolygon(4, quad4x, quad4y, wx, wy, 10, 10, 50, 50); T.setColor(1.0f, 0.0f, 1.0f); /* magenta */ T.printLoop(4, quad4x, quad4y); T.printPoly(wl, wx, wy); /* * fifth polygon: enclosing */ wl = 0; wl = T.clipPolygon(5, pent1x, pent1y, wx, wy, 90, 20, 100, 30); T.setColor(0.5f, 0.5f, 1.0f); /* reddish-greenish-blue ? */ T.printLoop(5, pent1x, pent1y); T.printPoly(wl, wx, wy); /* * sixth polygon: outside on left and bottom */ wl = 0; wl = T.clipPolygon(5, pent1x, pent1y, wx, wy, 90, 34, 120, 60); T.setColor(1.0f, 0.5f, 1.0f); /* red-greenish-blue ? */ T.printLoop(5, pent1x, pent1y); T.printPoly(wl, wx, wy); /* * seventh polygon: outside on top, right, and bottom */ wl = 0; wl = T.clipPolygon(7, hept1x, hept1y, wx, wy, 90, 80, 130, 110); T.setColor(0.0f, 0.0f, 0.0f); /* black */ T.printLoop(7, hept1x, hept1y); T.printPoly(wl, wx, wy); Frame f = new Frame("clip Test"); f.add("Center", T); f.pack(); f.setResizable(false); f.setVisible(true); }
RootWindow(Container container, Screen screen, Format[] format, Client c) { super(screen.rootId); rootwindow = container; client = c; screen.setRoot((Window) this); this.width = (short) (screen.width); this.height = (short) (screen.height); this.screen = screen; depth = screen.rootDepth; id = screen.rootId; type = DRAWABLE_WINDOW; x = y = 0; origin.x = 0; origin.y = 0; clss = (byte) InputOutput; for (int i = 0; i < format.length; i++) { if (format[i].depth == screen.rootDepth) { this.bitsPerPixel = format[i].bpp; } } setVisual(screen.rootVisual); setBackgroundIsPixel(); background.pixel = screen.white; setBorderIsPixel(); border.pixel = screen.black; borderWidth = 0; Resource.add(this); makeOptional(); attr &= ~(1 << 3); // cursorIsNone optional.cursor = Cursor.rootCursor; setColormap(screen.defaultColormap); // if(rootwindow instanceof JFrame){ // rootwindow.setSize(this.width+10, this.height+30); // ?? // } // else{ rootwindow.setSize(this.width, this.height); // } try { ddxwindow = (DDXWindow) (Window.dDXWindow.newInstance()); } catch (Exception e) { System.err.println(e); /*ddxwindow=new DDXWindowImp();*/ } ddxwindow.init(this); ddxwindow.setLocation(0, 0); if (rootwindow instanceof Frame) { // ((Frame)rootwindow).setLayout(null); ((Frame) rootwindow).setResizable(false); ((Frame) rootwindow).setMenuBar(null); ((Frame) rootwindow).add((java.awt.Component) ddxwindow); } else if (rootwindow instanceof Applet) { ((Applet) rootwindow).add((java.awt.Component) ddxwindow); } /* else if(rootwindow instanceof JFrame){ ((JFrame)rootwindow).getContentPane().setLayout(null); ((JFrame)rootwindow).setResizable(false); ((JFrame)rootwindow).setJMenuBar(null); ((JFrame)rootwindow).getContentPane().add((java.awt.Component)ddxwindow); } else if(rootwindow instanceof JWindow){ ((JWindow)rootwindow).getContentPane().setLayout(null); ((JWindow)rootwindow).getContentPane().add((java.awt.Component)ddxwindow); } else if (rootwindow instanceof JApplet){ ((JApplet)rootwindow).setJMenuBar(null); ((JApplet)rootwindow).getContentPane().add((java.awt.Component)ddxwindow); } */ else { rootwindow.add((java.awt.Component) ddxwindow); } if (screen.windowmode != WeirdX.InBrowser) { rootwindow.addNotify(); } else { rootwindow.setVisible(true); } ddxwindow.setVisible(true); { rootwindow.validate(); Insets insets = rootwindow.getInsets(); rootwindow.setSize( this.width + insets.left + insets.right, this.height + insets.top + insets.bottom); ddxwindow.setLocation(insets.left, insets.top); rootwindow.validate(); } ddxwindow.requestFocus(); Window.focus.win = id; Window.LOCK = rootwindow.getTreeLock(); Client.LOCK = rootwindow.getTreeLock(); Resource.LOCK = rootwindow.getTreeLock(); spriteTrace[0] = this; sprite.win = this; }