1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216
|
/*
* Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
* Copyright (C) 2007 - INRIA - Vincent Couvert
* Copyright (C) 2007 - INRIA - Marouane BEN JELLOUL
*
* This file must be used under the terms of the CeCILL.
* This source file is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
* are also available at
* http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt
*
*/
package org.scilab.modules.gui.canvas;
import java.awt.image.BufferedImage;
import com.jogamp.opengl.GL;
import org.scilab.modules.gui.bridge.ScilabBridge;
import org.scilab.modules.gui.dockable.ScilabDockable;
import org.scilab.modules.gui.menubar.MenuBar;
import org.scilab.modules.gui.toolbar.ToolBar;
import org.scilab.modules.gui.utils.Position;
import org.scilab.modules.gui.utils.Size;
/**
* Class for Scilab Canvas in GUIs
* @author Vincent COUVERT
* @author Marouane BEN JELLOUL
*/
public class ScilabCanvas extends ScilabDockable implements Canvas {
private SimpleCanvas component;
/**
* Constructor
* @param figureIndex index of the displayed figure
* @param antialiasingQuality Specify the number of pass to use for antialiasing.
* If its value is 0, then antialiasing is disable.
*/
protected ScilabCanvas(int figureIndex, int antialiasingQuality) {
component = ScilabBridge.createCanvas(figureIndex, antialiasingQuality);
}
/**
* Creates a Scilab Canvas
* @param figureIndex index of the displayed figure
* @param antialiasingQuality Specify the number of pass to use for antialiasing.
* If its value is 0, then antialiasing is disable.
* @return the created canvas
*/
public static Canvas createCanvas(int figureIndex, int antialiasingQuality) {
return new ScilabCanvas(figureIndex, antialiasingQuality);
}
/**
* Gets this Bridge component object
* @return this Bridge component object
*/
public SimpleCanvas getAsSimpleCanvas() {
return component;
}
/**
* Sets a MenuBar to an element
* @param newMenuBar the MenuBar to set to the element
*/
public void addMenuBar(MenuBar newMenuBar) {
// TODO Auto-generated method stub
throw new UnsupportedOperationException();
}
/**
* Sets a ToolBar to an element
* @param newToolBar the ToolBar to set to the element
*/
public void addToolBar(ToolBar newToolBar) {
// TODO Auto-generated method stub
throw new UnsupportedOperationException();
}
/**
* Draws a Scilab canvas
* @see org.scilab.modules.gui.UIElement#draw()
*/
public void draw() {
ScilabBridge.draw(this);
}
/**
* Gets the dimensions (width and height) of a Scilab Canvas
* @return the size of the canvas
* @see org.scilab.modules.gui.UIElement#getDims()
*/
public Size getDims() {
return ScilabBridge.getDims(this);
}
/**
* Gets the position (X-coordinate and Y-coordinate) of a Scilab canvas
* @return the position of the canvas
* @see org.scilab.modules.gui.UIElement#getPosition()
*/
public Position getPosition() {
return ScilabBridge.getPosition(this);
}
/**
* Gets the visibility status of a Scilab Canvas
* @return the visibility status of the canvas (true if the canvas is visible, false if not)
* @see org.scilab.modules.gui.UIElement#isVisible()
*/
public boolean isVisible() {
return ScilabBridge.isVisible(this);
}
/**
* Sets the dimensions (width and height) of a Scilab Canvas
* @param newSize the size we want to set to the canvas
* @see org.scilab.modules.gui.UIElement#setDims(org.scilab.modules.gui.utils.Size)
*/
public void setDims(Size newSize) {
ScilabBridge.setDims(this, newSize);
}
/**
* Sets the position (X-coordinate and Y-coordinate) of a Scilab canvas
* @param newPosition the position we want to set to the canvas
* @see org.scilab.modules.gui.UIElement#setPosition(org.scilab.modules.gui.utils.Position)
*/
public void setPosition(Position newPosition) {
ScilabBridge.setPosition(this, newPosition);
}
/**
* Sets the visibility status of a Scilab Canvas
* @param newVisibleState the visibility status we want to set to the canvas (true to set the canvas visible, false else)
* @see org.scilab.modules.gui.UIElement#setVisible(boolean)
*/
public void setVisible(boolean newVisibleState) {
ScilabBridge.setVisible(this, newVisibleState);
}
/**
* Force the canvas to render itself immediately.
*/
public void display() {
ScilabBridge.display(this);
}
/**
* Get the GL pipeline used by the canvas
* @return GL pipeline
*/
public GL getGL() {
return ScilabBridge.getGL(this);
}
/**
* @param onOrOff set wether the swap buffer mode is on or off.
*/
public void setAutoSwapBufferMode(boolean onOrOff) {
ScilabBridge.setAutoSwapBufferMode(this, onOrOff);
}
/**
* @return set wether the swap buffer mode is on or off.
*/
public boolean getAutoSwapBufferMode() {
return ScilabBridge.getAutoSwapBufferMode(this);
}
/**
* Force the canvas to render itself with synchronisation with its OpenGL process.
*/
public void repaint() {
ScilabBridge.repaint(this);
}
/**
* Set the background of the Canvas.
* @param red red channel
* @param green green channel
* @param blue blue channel
*/
public void setBackgroundColor(double red, double green, double blue) {
ScilabBridge.setBackgroundColor(this, red, green, blue);
}
/**
* Disable the canvas before closing
*/
public void close() {
ScilabBridge.close(this);
}
/**
* Convert to a BufferedImage
* @return BufferedImage
*/
public BufferedImage dumpAsBufferedImage() {
return ScilabBridge.dumpAsBufferedImage(this);
}
/**
* Set double buffer mode on or Off
* @param useSingleBuffer if true use single buffer if false use double buffering
*/
public void setSingleBuffered(boolean useSingleBuffer) {
ScilabBridge.setSingleBuffered(this, useSingleBuffer);
}
}
|