Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * To change this template, choose Tools | Templates
- * and open the template in the editor.
- */
- package jxa;
- import java.awt.datatransfer.DataFlavor;
- import java.awt.datatransfer.UnsupportedFlavorException;
- import java.io.IOException;
- import net.sf.jiga.xtended.ui.AntFrame;
- import java.awt.BorderLayout;
- import java.awt.Dimension;
- import java.awt.FlowLayout;
- import java.lang.reflect.InvocationTargetException;
- import java.util.Timer;
- import java.util.TimerTask;
- import java.util.Vector;
- import javax.swing.*;
- import net.sf.jiga.xtended.ui.DisplayInterface;
- import org.lwjgl.LWJGLException;
- import org.lwjgl.opengl.AWTGLCanvas;
- import org.lwjgl.opengl.PixelFormat;
- import static org.lwjgl.opengl.GL11.*;
- /**
- *
- * @author www.b23prodtm.info
- */
- public class NewClass implements AntFrame {
- /**
- * @param args args from java command-line
- */
- public NewClass(String[] args) {
- }
- public boolean open(Object o) {
- /**
- * ! implement with your code !
- */
- return false;
- }
- public boolean save(String string) {
- /**
- * ! implement with your code !
- */
- return false;
- }
- /**
- * ### APPLET SUPPORT ###
- */
- public void start() {
- /**
- * ! implement with your code !
- */
- TimerTask tt = new TimerTask() {
- public void run() {
- try {
- // this invokes update(g) on the EDT
- SwingUtilities.invokeAndWait(new Runnable() { // Wait for the task to complete, since we don't want to use this Timer for any other tasks
- // AWT/Swing will render Canvas on our Thread.
- public void run() {
- canvas.update(canvas.getGraphics());
- }
- });
- } catch (InterruptedException ex) {
- } catch (InvocationTargetException ex) {
- ex.printStackTrace();
- }
- }
- };
- // by using the Timer for our canvas OpenGL rendering, it ensures that AWT/Swing is able to handle all AWTEvent requests (Mouse, Components validation, Layout repaint, etc.) ASAP, seemlessly.
- Timer t = new Timer();
- t.scheduleAtFixedRate(tt, 0, 30);
- }
- /**
- * ### APPLET SUPPORT ###
- */
- public void stop() {
- /**
- * ! implement with your code !
- */
- }
- boolean initialized = false;
- public boolean isInitialized() {
- return initialized;
- }
- public Runnable shutdownHook() {
- /**
- * ! implement with your code !
- */
- return new Runnable() {
- public void run() {
- }
- };
- }
- public DataFlavor[] getTransferDataFlavors() {
- /**
- * ! implement with your code !
- */
- return new DataFlavor[]{};
- }
- public boolean isDataFlavorSupported(DataFlavor flavor) {
- /**
- * ! implement with your code !
- */
- return false;
- }
- public Object getTransferData(DataFlavor flavor) throws UnsupportedFlavorException, IOException {
- /**
- * ! implement with your code !
- */
- return null;
- }
- JApplet applet = null;
- /**
- * ### APPLET SUPPORT ###
- */
- public void setApplet(JApplet ja) {
- applet = ja;
- }
- /**
- * ### APPLET SUPPORT ###
- */
- public JApplet getApplet() {
- return applet;
- }
- /**
- * ### APPLET SUPPORT ###
- */
- public void destroy() {
- /**
- * ! implement with your code !
- */
- /**
- *
- */
- initialized = false;
- }
- /**
- * ### APPLET SUPPORT ###
- */
- public void init() {
- /**
- * ! implement with your code !
- */
- /**
- *
- */
- initialized = true;
- }
- JFrame frame = null;
- /**
- * ### JFRAME APP SUPPORT ###
- */
- public void setFrame(JFrame jframe) {
- frame = jframe;
- }
- /**
- * ### JFRAME APP SUPPORT ###
- */
- public JFrame getFrame() {
- return frame;
- }
- /**
- * ### JFRAME APP SUPPORT ###
- */
- public void destroyComponents() {
- /**
- * ! implement with your code !
- */
- /**
- *
- */
- initialized = false;
- }
- AWTGLCanvas canvas;
- /**
- * ### JFRAME APP SUPPORT ###
- */
- public void initComponents() {
- /**
- * ! implement with your code !
- */
- /**
- *
- */
- final JPanel panel_canvas = new JPanel();
- try {
- panel_canvas.add(canvas = new AWTGLCanvas(new PixelFormat(8, 8, 0, 4)) {
- final Dimension size = new Dimension(100, 100);
- @Override
- public void initGL() {
- setPreferredSize(size);
- setSize(size);
- glDisable(GL_DEPTH_TEST);
- glDisable(GL_CULL_FACE);
- }
- @Override
- public void paintGL() {
- try {
- glViewport(0, 0, getWidth(), getHeight());
- glColor3f(1, 0, 0);
- glBegin(GL_QUADS);
- glVertex2f(-1, -1);
- glVertex2f(1, -1);
- glVertex2f(1, 1);
- glVertex2f(-1, 1);
- glEnd();
- glFinish();
- swapBuffers();
- } catch (LWJGLException ex) {
- }
- }
- }, BorderLayout.CENTER);
- } catch (Exception e) {
- };
- JPanel panel_top = new JPanel(new FlowLayout());
- JPanel panel_bottom = new JPanel(new BorderLayout());/*
- * {
- *
- * @Override public void paint(Graphics g) {
- *
- * canvas.update(g); }
- };
- */
- panel_top.setPreferredSize(new Dimension(200, 300));
- panel_bottom.setPreferredSize(new Dimension(200, 300));
- panel_bottom.add(panel_canvas);
- JScrollPane scrollpane_top = new JScrollPane(panel_top);
- JScrollPane scrollpane_bottom = new JScrollPane(panel_bottom);
- JSplitPane splitpane = new JSplitPane(JSplitPane.VERTICAL_SPLIT);
- splitpane.setPreferredSize(new Dimension(200, 300));
- splitpane.setTopComponent(scrollpane_top);
- splitpane.setBottomComponent(scrollpane_bottom);
- splitpane.setContinuousLayout(true);
- splitpane.setResizeWeight(0.5f);
- frame.add(splitpane);
- frame.pack();
- frame.setVisible(true);
- initialized = true;
- }
- public DisplayInterface getSplash() {
- return null;
- }
- public Vector<Action> getLoadLayers() {
- return new Vector();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement