JAL-1807 Bob's first commit -- Applet loaded; needs image
[jalview.git] / src / javajs / api / GenericPlatform.java
1 package javajs.api;
2
3
4 import java.net.URL;
5 import java.util.Map;
6
7
8 import javajs.awt.Font;
9 import javajs.util.P3;
10
11 public interface GenericPlatform extends FontManager {
12
13   public final static int CURSOR_DEFAULT = 0;
14   public final static int CURSOR_CROSSHAIR = 1;
15   public final static int CURSOR_WAIT = 3;
16   public final static int CURSOR_ZOOM = 8;
17   public final static int CURSOR_HAND = 12;
18   public final static int CURSOR_MOVE = 13;
19
20   void setViewer(PlatformViewer vwr, Object display);
21   
22   /////// Display
23
24   boolean isHeadless();
25   
26   void convertPointFromScreen(Object display, P3 ptTemp);
27
28   void getFullScreenDimensions(Object display, int[] widthHeight);
29   
30   boolean hasFocus(Object display);
31
32   String prompt(String label, String data, String[] list, boolean asButtons);
33
34   void repaint(Object display);
35
36   void requestFocusInWindow(Object display);
37
38   void setCursor(int i, Object display);
39
40   void setTransparentCursor(Object display);
41
42   ////  Mouse 
43
44   GenericMouseInterface getMouseManager(double privateKey, Object display);
45
46   ///// core Image handling
47   
48   Object allocateRgbImage(int windowWidth, int windowHeight, int[] pBuffer,
49                           int windowSize, boolean backgroundTransparent, boolean isImageWrite);
50
51   void disposeGraphics(Object graphicForText);
52
53   void drawImage(Object g, Object img, int x, int y, int width, int height);
54
55   int[] drawImageToBuffer(Object gObj, Object imageOffscreen,
56                           Object image, int width, int height, int bgcolor);
57
58   void flushImage(Object imagePixelBuffer);
59
60   Object getStaticGraphics(Object image, boolean backgroundTransparent);
61
62   Object getGraphics(Object image);
63
64   int getImageWidth(Object image);
65
66   int getImageHeight(Object image);
67
68   Object newBufferedImage(Object image, int i, int height);
69
70   Object newOffScreenImage(int w, int h);
71   
72   @Deprecated
73   void renderScreenImage(Object g, Object currentSize);
74
75   int[] getTextPixels(String text, Font font3d, Object gObj,
76                       Object image, int mapWidth, int height,
77                       int ascent);
78
79   ///// Image creation for export (optional for any platform)
80
81   /**
82    * can be ignored (return null) if platform cannot save images
83    * 
84    * @param ret
85    * @return     null only if this platform cannot save images
86    */
87   Object createImage(Object ret);
88
89   /**
90    * 
91    * @param image
92    * @param width
93    * @param height
94    * @param pixels 
95    * @param startRow 
96    * @param nRows 
97    * @return         pixels
98    */
99   int[] grabPixels(Object image, int width, int height, 
100                    int[] pixels, int startRow, int nRows);
101
102   /**
103    * can be ignored (return false) if platform cannot save images
104    * 
105    * @param boolIsEcho
106    * @param image
107    * @return        false only if this platform cannot save images
108    * @throws InterruptedException
109    */
110   boolean waitForDisplay(Object boolIsEcho, Object image) throws InterruptedException;
111
112   GenericMenuInterface getMenuPopup(String menuStructure, char type);
113
114   Object getJsObjectInfo(Object[] jsObject, String method, Object[] args);
115
116   boolean isSingleThreaded();
117
118   void notifyEndOfRendering();
119
120   String getDateFormat(String isoType);
121   
122   GenericFileInterface newFile(String name);
123   
124   Object getBufferedFileInputStream(String name);
125   
126   /**
127    * 
128    * @param url
129    * @param outputBytes
130    * @param post
131    * @param asString
132    * @return may be javajs.util.SB or byte[] or java.io.InputStream
133    */
134   Object getURLContents(URL url, byte[] outputBytes, String post, boolean asString);
135
136   String getLocalUrl(String fileName);
137
138   GenericImageDialog getImageDialog(String title,
139                                  Map<String, GenericImageDialog> imageMap);
140
141 }