Merge branch 'master' of https://source.jalview.org/git/jalviewjs.git
[jalviewjs.git] / src / javajs / awt / Component.java
index 4a24ddf..505d0b3 100644 (file)
-package javajs.awt;\r
-\r
-import javajs.api.GenericColor;\r
-import javajs.util.CU;\r
-\r
-abstract public class Component {\r
-\r
-  protected boolean visible;  \r
-  protected boolean enabled = true;\r
-  protected String text;    \r
-  protected String name;\r
-  protected int width;\r
-  protected int height;\r
-  protected String id;\r
-\r
-  protected Object parent;\r
-  \r
-  public void setParent(Object p) {\r
-    parent = p;\r
-  }\r
-\r
-  protected Object mouseListener;\r
-\r
-  private GenericColor bgcolor;\r
-\r
-  protected Component(String type) {\r
-    id = newID(type);\r
-    if (type == null)\r
-      return;\r
-    /**\r
-     * @j2sNative\r
-     *            SwingController.register(this, type);\r
-     */\r
-    {\r
-    }\r
-\r
-  }\r
-  \r
-  public static String newID(String type) {\r
-    return type + ("" + Math.random()).substring(3, 10);\r
-  }\r
-\r
-  abstract public String toHTML();\r
-  \r
-  public void setBackground(GenericColor color) {\r
-    bgcolor = color;\r
-  }\r
-\r
-  public void setText(String text) {\r
-    this.text = text;\r
-    /**\r
-     * @j2sNative\r
-     * \r
-     * SwingController.setText(this);\r
-     * \r
-     */\r
-    {\r
-    }\r
-  }\r
-\r
-  public void setName(String name) {\r
-    this.name = name;\r
-  }\r
-\r
-  public String getName() {\r
-    return name;\r
-  }\r
-  \r
-  public Object getParent() {\r
-    return parent;\r
-  }\r
-  \r
-  public void setPreferredSize(Dimension dimension) {\r
-    this.width = dimension.width;\r
-    this.height = dimension.height;   \r
-  }\r
-\r
-  public void addMouseListener(Object listener) {\r
-    mouseListener = listener;\r
-  }\r
-\r
-  public String getText() {\r
-    return text;\r
-  }\r
-\r
-  public boolean isEnabled() {\r
-    return enabled;\r
-  }\r
-  \r
-  public void setEnabled(boolean enabled) {\r
-    this.enabled = enabled;\r
-    /**\r
-     * @j2sNative\r
-     * \r
-     * SwingController.setEnabled(this);\r
-     * \r
-     */\r
-    {}\r
-  }\r
-\r
-  public boolean isVisible() {\r
-    return visible;\r
-  }\r
-\r
-  public void setVisible(boolean visible) {\r
-    this.visible = visible;\r
-    /**\r
-     * @j2sNative\r
-     * \r
-     * SwingController.setVisible(this);\r
-     * \r
-     */\r
-    {}\r
-  }\r
-\r
-  public int getHeight() {\r
-    return height;\r
-  }\r
-\r
-  public int getWidth() {\r
-    return width;\r
-  }\r
-\r
-  protected int minWidth = 30;\r
-  protected int minHeight = 30;\r
-\r
-  public void setMinimumSize(Dimension d) {\r
-    minWidth = d.width;\r
-    minHeight = d.height;\r
-  }\r
-\r
-  public int getSubcomponentWidth() {\r
-    return width;\r
-  }\r
-  \r
-  public int getSubcomponentHeight() {\r
-    return height;\r
-  }\r
-  \r
-  protected int renderWidth;\r
-  protected int renderHeight;\r
-\r
-  protected String getCSSstyle(int defaultPercentW, int defaultPercentH) {\r
-    int width = (renderWidth > 0 ? renderWidth : getSubcomponentWidth());\r
-    int height = (renderHeight > 0 ? renderHeight : getSubcomponentHeight());\r
-    return (width > 0 ? "width:" + width +"px;" : defaultPercentW > 0 ? "width:"+defaultPercentW+"%;" : "")\r
-    + (height > 0 ?"height:" + height + "px;" : defaultPercentH > 0 ? "height:"+defaultPercentH+"%;" : "")\r
-    + (bgcolor == null ? "" : "background-color:" + CU.toCSSString(bgcolor) + ";");\r
-  }\r
-  \r
-  public void repaint() {\r
-    // for inheritance\r
-  }\r
-\r
-}\r
+package javajs.awt;
+
+import javajs.api.GenericColor;
+import javajs.util.CU;
+
+abstract public class Component {
+
+  protected boolean visible;  
+  protected boolean enabled = true;
+  protected String text;    
+  protected String name;
+  protected int width;
+  protected int height;
+  protected String id;
+
+  protected Object parent;
+  
+  public void setParent(Object p) {
+    parent = p;
+  }
+
+  protected Object mouseListener;
+
+  private GenericColor bgcolor;
+
+  protected Component(String type) {
+    id = newID(type);
+    if (type == null)
+      return;
+    /**
+     * @j2sNative
+     *            SwingController.register(this, type);
+     */
+    {
+    }
+
+  }
+  
+  public static String newID(String type) {
+    return type + ("" + Math.random()).substring(3, 10);
+  }
+
+  abstract public String toHTML();
+  
+  public void setBackground(GenericColor color) {
+    bgcolor = color;
+  }
+
+  public void setText(String text) {
+    this.text = text;
+    /**
+     * @j2sNative
+     * 
+     * SwingController.setText(this);
+     * 
+     */
+    {
+    }
+  }
+
+  public void setName(String name) {
+    this.name = name;
+  }
+
+  public String getName() {
+    return name;
+  }
+  
+  public Object getParent() {
+    return parent;
+  }
+  
+  public void setPreferredSize(Dimension dimension) {
+    this.width = dimension.width;
+    this.height = dimension.height;   
+  }
+
+  public void addMouseListener(Object listener) {
+    mouseListener = listener;
+  }
+
+  public String getText() {
+    return text;
+  }
+
+  public boolean isEnabled() {
+    return enabled;
+  }
+  
+  public void setEnabled(boolean enabled) {
+    this.enabled = enabled;
+    /**
+     * @j2sNative
+     * 
+     * SwingController.setEnabled(this);
+     * 
+     */
+    {}
+  }
+
+  public boolean isVisible() {
+    return visible;
+  }
+
+  public void setVisible(boolean visible) {
+    this.visible = visible;
+    /**
+     * @j2sNative
+     * 
+     * SwingController.setVisible(this);
+     * 
+     */
+    {}
+  }
+
+  public int getHeight() {
+    return height;
+  }
+
+  public int getWidth() {
+    return width;
+  }
+
+  protected int minWidth = 30;
+  protected int minHeight = 30;
+
+  public void setMinimumSize(Dimension d) {
+    minWidth = d.width;
+    minHeight = d.height;
+  }
+
+  public int getSubcomponentWidth() {
+    return width;
+  }
+  
+  public int getSubcomponentHeight() {
+    return height;
+  }
+  
+  protected int renderWidth;
+  protected int renderHeight;
+
+  protected String getCSSstyle(int defaultPercentW, int defaultPercentH) {
+    int width = (renderWidth > 0 ? renderWidth : getSubcomponentWidth());
+    int height = (renderHeight > 0 ? renderHeight : getSubcomponentHeight());
+    return (width > 0 ? "width:" + width +"px;" : defaultPercentW > 0 ? "width:"+defaultPercentW+"%;" : "")
+    + (height > 0 ?"height:" + height + "px;" : defaultPercentH > 0 ? "height:"+defaultPercentH+"%;" : "")
+    + (bgcolor == null ? "" : "background-color:" + CU.toCSSString(bgcolor) + ";");
+  }
+  
+  public void repaint() {
+    // for inheritance
+  }
+
+}