jhplot.gui
Class GHPanel
- java.lang.Object
-
- jhplot.gui.GHPanel
-
- All Implemented Interfaces:
- java.awt.event.ComponentListener, java.io.Serializable, java.util.EventListener
- Direct Known Subclasses:
- GHFrame
public class GHPanel extends java.lang.Object implements java.awt.event.ComponentListener, java.io.Serializable
Class to build the global panel with graphics. It should be inserted to some frame. It has 4 margins which can be obtained from this class.- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor and Description GHPanel(int Width, int Height)
Create a panel with graphics.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method and Description void
addComp(java.awt.Component a)
Add a component to the main panelvoid
addGraph(int i1, int i2, java.awt.Component a)
Add a graph or any component in the location given by i1 and i2void
componentHidden(java.awt.event.ComponentEvent e)
void
componentMoved(java.awt.event.ComponentEvent e)
void
componentResized(java.awt.event.ComponentEvent e)
void
componentShown(java.awt.event.ComponentEvent e)
void
convertSVG(java.lang.String source, java.lang.String target)
Export SVG to various image formats.void
convertSVG(java.lang.String source, java.lang.String target, boolean isRemove)
Export SVG to various image formats.static void
disableDoubleBuffering(java.awt.Component c)
static void
enableDoubleBuffering(java.awt.Component c)
void
export(java.lang.String file)
Fast export of the canvas to an image file.javax.swing.JPanel
getCanvasPanel()
get JPanel for the main panel which keeps the central panel and all 4 marginsjava.awt.Color
getMarginBackground()
Get color for all global marginsjavax.swing.JPanel
getMarginPanelBottom()
get JPanel for bottom marginjavax.swing.JPanel
getMarginPanelCenter()
get JPanel for central with drawingsjavax.swing.JPanel
getMarginPanelLeft()
get JPanel for left marginjavax.swing.JPanel
getMarginPanelRight()
get JPanel for right marginjavax.swing.JPanel
getMarginPanelTop()
get JPanel for top margindouble
getMarginSizeBottom()
Get size of the bottom margin as ratio to the main paneldouble
getMarginSizeLeft()
Get the size of left margin terms of the ratio to the main paneldouble
getMarginSizeRight()
Get the size of right margin of the global canvas in terms of the ratio to thye global canvasdouble
getMarginSizeTop()
Get size of the top margin of global canvas in terms of ratio to the main panelint
getSizeX()
Get the width of the main panel which keeps all margins and the central panel (in pixels)int
getSizeY()
Get the height of the main panel which keeps all margins and the central panel (in pixels)java.lang.String
getTextBottom()
Get the text of bottom margin.java.awt.Color
getTextBottomColor()
Get the color of bottom margin for the text.java.awt.Color
getTextBottomColorBack()
Get the background color of bottom marginjava.awt.Font
getTextBottomFont()
Get the font of bottom margin.java.lang.String
getTextLeft()
Get the text of left margin.java.awt.Color
getTextLeftColor()
Get the color of bottom margin for the text.java.awt.Color
getTextLeftColorBack()
Get the background color of left marginjava.awt.Font
getTextLeftFont()
Get the font of left margin.double
getTextPosBottomX()
Get the text position in X relative to widths for bottom margindouble
getTextPosBottomY()
Get the text position in Y relative to widths for bottom margindouble
getTextPosLeftX()
Get the text position in X relative to widths for left margindouble
getTextPosLeftY()
Get the text position in Y relative to widths for left margindouble
getTextPosRightX()
Get the text position in X relative to widths for right margindouble
getTextPosRightY()
Get the text position in Y relative to widths for right margindouble
getTextPosTopX()
Get the text position in X relative to widths for top margindouble
getTextPosTopY()
Get the text position in Y relative to widths for top marginjava.lang.String
getTextRight()
Get text of right margin.java.awt.Color
getTextRightColor()
Get the color of right margin for the text.java.awt.Color
getTextRightColorBack()
Get the background color of right marginjava.awt.Font
getTextRightFont()
Get the font of right margin.int
getTextRotationBottom()
Get the text rotation for bottom marginint
getTextRotationLeft()
Get the text rotation for left marginint
getTextRotationRight()
Get the text rotation for right marginint
getTextRotationTop()
Get the text rotation for top marginjava.lang.String
getTextTop()
Get text of top margin (title).java.awt.Color
getTextTopColor()
Get the color of top margin for the text.java.awt.Color
getTextTopColorBack()
Get the background color of top marginjava.awt.Font
getTextTopFont()
Get the font of top marginboolean
isBorderShown()
is the boarder of margins shown?void
printGraph()
Print the canvasvoid
resetMargins()
Reset all margins to the default values.void
setGTitle(java.lang.String sname)
Set the global title with default attributes.void
setGTitle(java.lang.String sname, java.awt.Color c)
Set the global title.void
setGTitle(java.lang.String sname, double space)
Set the global title with default attributes.void
setGTitle(java.lang.String sname, java.awt.Font f)
Sets the global title using black color.void
setGTitle(java.lang.String sname, java.awt.Font f, java.awt.Color c)
Sets the global titlevoid
setMarginBackground(java.awt.Color backMargin)
Set color for all global marginsvoid
setMarginSizeBottom(double bottomSize)
Set size of the bottom margin of global canvas in terms of the ratio to the size of the main panelvoid
setMarginSizeLeft(double leftSize)
Set the size of left margin in term of the ratio to the global panelvoid
setMarginSizeRight(double rightSize)
Set the size of right margin of the global canvas in terms of the ration to the global panel in Xvoid
setMarginSizeTop(double topSize)
Set size of the top margin of global canvas in terms of the ratio to the size of the main panelvoid
setSizePanel(int Width, int Height)
Set the size of the global panel which keeps the central panel and the marginsvoid
setTextBottom(java.lang.String sname)
Set the global bottom margin with default attributes.void
setTextBottom(java.lang.String sname, double space)
Set the global bottom margin with default attributes.void
setTextBottom(java.lang.String sname, java.awt.Font f)
Sets a text on global bottom margin using black color.void
setTextBottom(java.lang.String sname, java.awt.Font f, java.awt.Color c)
Sets a text on global bottom margin.void
setTextBottomColorBack(java.awt.Color c)
Get the background color of bottom marginvoid
setTextLeft(java.lang.String sname)
Set the global left margin with default attributes.void
setTextLeft(java.lang.String sname, double space)
Set the global left margin with default attributes.void
setTextLeft(java.lang.String sname, java.awt.Font f)
Sets a text on global left margin using black color.void
setTextLeft(java.lang.String sname, java.awt.Font f, java.awt.Color c)
Sets a text on global left marginvoid
setTextLeftColorBack(java.awt.Color c)
Get the background color of left marginvoid
setTextPosBottomX(double x)
Set the text position in X relative to width for bottom marginvoid
setTextPosBottomY(double y)
Set the text position in Y relative to width for bottom marginvoid
setTextPosLeftX(double x)
Set the text position in X relative to width for left marginvoid
setTextPosLeftY(double y)
Set the text position in Y relative to width for left marginvoid
setTextPosRightX(double x)
Set the text position in X relative to width for right marginvoid
setTextPosRightY(double y)
Set the text position in Y relative to width for right marginvoid
setTextPosTopX(double x)
Set the text position in X relative to width for top marginvoid
setTextPosTopY(double y)
Set the text position in Y relative to width for top marginvoid
setTextRight(java.lang.String sname)
Set the global right margin with default attributes.void
setTextRight(java.lang.String sname, double space)
Set the global right margin with default attributes.void
setTextRight(java.lang.String sname, java.awt.Font f)
Sets a text on global right margin using black color.void
setTextRight(java.lang.String sname, java.awt.Font f, java.awt.Color c)
Sets a text on global right marginvoid
setTextRightColorBack(java.awt.Color c)
Get the background color of left marginvoid
setTextRotationBottom(int r)
Set the text rotation for bottom marginvoid
setTextRotationLeft(int r)
Set the text rotation for left marginvoid
setTextRotationRight(int r)
Set the text rotation for right marginvoid
setTextRotationTop(int r)
Set the text rotation for top marginvoid
setTextTop(java.lang.String sname)
Set the global top margin with default attributes.void
setTextTop(java.lang.String sname, java.awt.Font f)
Sets a text on global top margin using black color.void
setTextTop(java.lang.String sname, java.awt.Font f, java.awt.Color c)
Sets a text on global top marginvoid
setTextTopColorBack(java.awt.Color c)
Get the background color of top marginvoid
showBorders(boolean show)
Show borders of margins for edditing
-
-
-
Constructor Detail
-
GHPanel
public GHPanel(int Width, int Height)
Create a panel with graphics. By default, all margins have size of 10 pixels. Background color is white. Initialization of JHPLot classes are done here.- Parameters:
Width
- in pixelsHeight
- in pixels
-
-
Method Detail
-
convertSVG
public void convertSVG(java.lang.String source, java.lang.String target)
Export SVG to various image formats. Supported output: JPEG
PNG
PS
EPS
PDF
SVGZ- Parameters:
source
- Input file in SVG formattarget
- Output file in designed format.
-
convertSVG
public void convertSVG(java.lang.String source, java.lang.String target, boolean isRemove)
Export SVG to various image formats. Supported output: JPEG
PNG
PS
EPS
PDF
SVGZ- Parameters:
source
- Input file in SVG formattarget
- Output file in designed format.isRemove
- true if the source should be removed.
-
addGraph
public void addGraph(int i1, int i2, java.awt.Component a)
Add a graph or any component in the location given by i1 and i2- Parameters:
i1
- location in xi2
- location in ya
- component
-
setMarginBackground
public void setMarginBackground(java.awt.Color backMargin)
Set color for all global margins- Parameters:
backMargin
-
-
getMarginBackground
public java.awt.Color getMarginBackground()
Get color for all global margins- Returns:
- color color of the margins
-
addComp
public void addComp(java.awt.Component a)
Add a component to the main panel- Parameters:
a
- Component
-
getSizeX
public int getSizeX()
Get the width of the main panel which keeps all margins and the central panel (in pixels)- Returns:
- size in X direction (width)
-
getSizeY
public int getSizeY()
Get the height of the main panel which keeps all margins and the central panel (in pixels)- Returns:
- size in Y direction (height)
-
setGTitle
public void setGTitle(java.lang.String sname, java.awt.Font f, java.awt.Color c)
Sets the global title- Parameters:
sname
- Titlef
- Fontc
- Color
-
setTextTop
public void setTextTop(java.lang.String sname, java.awt.Font f, java.awt.Color c)
Sets a text on global top margin- Parameters:
sname
- Titlef
- Fontc
- Color
-
setTextLeft
public void setTextLeft(java.lang.String sname, java.awt.Font f, java.awt.Color c)
Sets a text on global left margin- Parameters:
sname
- Titlef
- Fontc
- Color
-
setTextRight
public void setTextRight(java.lang.String sname, java.awt.Font f, java.awt.Color c)
Sets a text on global right margin- Parameters:
sname
- Titlef
- Fontc
- Color
-
setTextBottom
public void setTextBottom(java.lang.String sname, java.awt.Font f, java.awt.Color c)
Sets a text on global bottom margin.- Parameters:
sname
- Titlef
- Fontc
- Color
-
getTextBottom
public java.lang.String getTextBottom()
Get the text of bottom margin.- Returns:
- Text
-
getTextBottomFont
public java.awt.Font getTextBottomFont()
Get the font of bottom margin.- Returns:
- Font
-
getTextBottomColor
public java.awt.Color getTextBottomColor()
Get the color of bottom margin for the text.- Returns:
- Color of text
-
getTextLeft
public java.lang.String getTextLeft()
Get the text of left margin.- Returns:
- Text
-
getTextLeftFont
public java.awt.Font getTextLeftFont()
Get the font of left margin.- Returns:
- Font
-
export
public void export(java.lang.String file)
Fast export of the canvas to an image file. This depends on the extension:
SVG - Scalable Vector Graphics (SVG)
SVGZ - compressed SVG
JPG
PNG
PDF
EPS
PS.
Note: EPS, PDF and PS are derived from SVG. Use SVGZ to have smaller file sizes.No questions will be asked and existing file will be rewritten
- Parameters:
file
- Output file with the proper extension (SVG, SVGZ, JPG, PNG, PDF, EPS, PS). If no extension, PNG file is assumed.
-
getTextLeftColor
public java.awt.Color getTextLeftColor()
Get the color of bottom margin for the text.- Returns:
- Color of text
-
getTextTop
public java.lang.String getTextTop()
Get text of top margin (title).- Returns:
- Text of the top margin
-
getTextTopFont
public java.awt.Font getTextTopFont()
Get the font of top margin- Returns:
- Font
-
getTextTopColor
public java.awt.Color getTextTopColor()
Get the color of top margin for the text.- Returns:
- Color
-
getTextRight
public java.lang.String getTextRight()
Get text of right margin.- Returns:
- text on the right panel
-
getTextRightFont
public java.awt.Font getTextRightFont()
Get the font of right margin.- Returns:
- Font of the right panel
-
getTextRightColor
public java.awt.Color getTextRightColor()
Get the color of right margin for the text.- Returns:
- Color
-
setGTitle
public void setGTitle(java.lang.String sname, java.awt.Font f)
Sets the global title using black color.- Parameters:
sname
- Title namef
- Font
-
setTextLeft
public void setTextLeft(java.lang.String sname, java.awt.Font f)
Sets a text on global left margin using black color.- Parameters:
sname
- Titlef
- Font
-
setTextTop
public void setTextTop(java.lang.String sname, java.awt.Font f)
Sets a text on global top margin using black color.- Parameters:
sname
- Titlef
- Font
-
setTextRight
public void setTextRight(java.lang.String sname, java.awt.Font f)
Sets a text on global right margin using black color.- Parameters:
sname
- Titlef
- Font
-
setTextBottom
public void setTextBottom(java.lang.String sname, java.awt.Font f)
Sets a text on global bottom margin using black color.- Parameters:
sname
- Titlef
- Font
-
setGTitle
public void setGTitle(java.lang.String sname)
Set the global title with default attributes. The default color is black. The default font is ("Lucida Sans", Font.BOLD, 20)- Parameters:
sname
- Title
-
setGTitle
public void setGTitle(java.lang.String sname, double space)
Set the global title with default attributes. The default color is black. The default font is ("Lucida Sans", Font.BOLD, 20)- Parameters:
sname
- Titlespace
- size of the top margin (0-1)
-
setTextLeft
public void setTextLeft(java.lang.String sname)
Set the global left margin with default attributes. The default color is black. The default font is ("Lucida Sans", Font.BOLD, 18)- Parameters:
sname
- Title
-
setTextLeft
public void setTextLeft(java.lang.String sname, double space)
Set the global left margin with default attributes. The default color is black. The default font is ("Lucida Sans", Font.BOLD, 18)- Parameters:
sname
- Titlespace
- size of the left margin (0-1)
-
setTextRight
public void setTextRight(java.lang.String sname)
Set the global right margin with default attributes. The default color is black. The default font is ("Lucida Sans", Font.BOLD, 18)- Parameters:
sname
- Title
-
setTextRight
public void setTextRight(java.lang.String sname, double space)
Set the global right margin with default attributes. The default color is black. The default font is ("Lucida Sans", Font.BOLD, 18)- Parameters:
sname
- Titlespace
- size of the right margin (0-1)
-
setTextBottom
public void setTextBottom(java.lang.String sname)
Set the global bottom margin with default attributes. The default color is black. The default font is ("Lucida Sans", Font.BOLD, 18)- Parameters:
sname
- Title
-
setTextTop
public void setTextTop(java.lang.String sname)
Set the global top margin with default attributes. The default color is black. The default font is ("Lucida Sans", Font.BOLD, 18)- Parameters:
sname
- Title
-
resetMargins
public void resetMargins()
Reset all margins to the default values.
-
setTextBottom
public void setTextBottom(java.lang.String sname, double space)
Set the global bottom margin with default attributes. The default color is black. The default font is ("Lucida Sans", Font.BOLD, 18)- Parameters:
sname
- Titlespace
- size of the bottom margin (0-1)
-
setGTitle
public void setGTitle(java.lang.String sname, java.awt.Color c)
Set the global title. The default font is ("Lucida Sans", Font.BOLD, 20)- Parameters:
sname
- Titlec
- Color
-
getMarginPanelLeft
public javax.swing.JPanel getMarginPanelLeft()
get JPanel for left margin- Returns:
- JPanel
-
getMarginPanelRight
public javax.swing.JPanel getMarginPanelRight()
get JPanel for right margin- Returns:
- JPanel for right margin
-
getMarginPanelTop
public javax.swing.JPanel getMarginPanelTop()
get JPanel for top margin- Returns:
- JPanel for top margin
-
getMarginPanelBottom
public javax.swing.JPanel getMarginPanelBottom()
get JPanel for bottom margin- Returns:
- JPanel for bottom margin
-
getMarginPanelCenter
public javax.swing.JPanel getMarginPanelCenter()
get JPanel for central with drawings- Returns:
- central JPanel
-
getCanvasPanel
public javax.swing.JPanel getCanvasPanel()
get JPanel for the main panel which keeps the central panel and all 4 margins- Returns:
- JPanel Main panel
-
setTextRotationTop
public void setTextRotationTop(int r)
Set the text rotation for top margin- Parameters:
r
- rotation (0, 90, -90)
-
getTextRotationTop
public int getTextRotationTop()
Get the text rotation for top margin- Returns:
- rotation (0, 90, -90)
-
setTextRotationLeft
public void setTextRotationLeft(int r)
Set the text rotation for left margin- Parameters:
r
- rotation (0, 90, -90)
-
getTextRotationLeft
public int getTextRotationLeft()
Get the text rotation for left margin- Returns:
- rotation (0, 90, -90)
-
setTextRotationRight
public void setTextRotationRight(int r)
Set the text rotation for right margin- Parameters:
r
- rotation (0, 90, -90)
-
getTextRotationRight
public int getTextRotationRight()
Get the text rotation for right margin- Returns:
- rotation (0, 90, -90)
-
setTextRotationBottom
public void setTextRotationBottom(int r)
Set the text rotation for bottom margin- Parameters:
r
- rotation (0, 90, -90)
-
getTextRotationBottom
public int getTextRotationBottom()
Get the text rotation for bottom margin- Returns:
- rotation (0, 90, -90)
-
setTextPosTopX
public void setTextPosTopX(double x)
Set the text position in X relative to width for top margin- Parameters:
x
- position of text in X (from 0 to 1)
-
setTextPosTopY
public void setTextPosTopY(double y)
Set the text position in Y relative to width for top margin- Parameters:
y
- position of text in Y (from 0 to 1)
-
getTextPosTopX
public double getTextPosTopX()
Get the text position in X relative to widths for top margin- Returns:
- position of text in X (from 0 to 1)
-
getTextPosTopY
public double getTextPosTopY()
Get the text position in Y relative to widths for top margin- Returns:
- position of text in Y (from 0 to 1)
-
setTextPosLeftX
public void setTextPosLeftX(double x)
Set the text position in X relative to width for left margin- Parameters:
x
- position of text in X (from 0 to 1)
-
setTextPosLeftY
public void setTextPosLeftY(double y)
Set the text position in Y relative to width for left margin- Parameters:
y
- position of text in Y (from 0 to 1)
-
getTextPosLeftX
public double getTextPosLeftX()
Get the text position in X relative to widths for left margin- Returns:
- position of text in X (from 0 to 1)
-
getTextPosLeftY
public double getTextPosLeftY()
Get the text position in Y relative to widths for left margin- Returns:
- position of text in Y (from 0 to 1)
-
setTextPosRightX
public void setTextPosRightX(double x)
Set the text position in X relative to width for right margin- Parameters:
x
- position of text in X (from 0 to 1)
-
setTextPosRightY
public void setTextPosRightY(double y)
Set the text position in Y relative to width for right margin- Parameters:
y
- position of text in Y (from 0 to 1)
-
getTextPosRightX
public double getTextPosRightX()
Get the text position in X relative to widths for right margin- Returns:
- position of text in X (from 0 to 1)
-
getTextPosRightY
public double getTextPosRightY()
Get the text position in Y relative to widths for right margin- Returns:
- position of text in Y (from 0 to 1)
-
setTextPosBottomX
public void setTextPosBottomX(double x)
Set the text position in X relative to width for bottom margin- Parameters:
x
- position of text in X (from 0 to 1)
-
setTextPosBottomY
public void setTextPosBottomY(double y)
Set the text position in Y relative to width for bottom margin- Parameters:
y
- position of text in Y (from 0 to 1)
-
getTextPosBottomX
public double getTextPosBottomX()
Get the text position in X relative to widths for bottom margin- Returns:
- position of text in X (from 0 to 1)
-
getTextPosBottomY
public double getTextPosBottomY()
Get the text position in Y relative to widths for bottom margin- Returns:
- position of text in Y (from 0 to 1)
-
getTextBottomColorBack
public java.awt.Color getTextBottomColorBack()
Get the background color of bottom margin- Returns:
- Color
-
setTextBottomColorBack
public void setTextBottomColorBack(java.awt.Color c)
Get the background color of bottom margin- Parameters:
c
- Color
-
getTextTopColorBack
public java.awt.Color getTextTopColorBack()
Get the background color of top margin- Returns:
- Color
-
setTextTopColorBack
public void setTextTopColorBack(java.awt.Color c)
Get the background color of top margin- Parameters:
c
- Color
-
getTextLeftColorBack
public java.awt.Color getTextLeftColorBack()
Get the background color of left margin- Returns:
- Color
-
setTextLeftColorBack
public void setTextLeftColorBack(java.awt.Color c)
Get the background color of left margin- Parameters:
c
- Color
-
getTextRightColorBack
public java.awt.Color getTextRightColorBack()
Get the background color of right margin- Returns:
- Color
-
setTextRightColorBack
public void setTextRightColorBack(java.awt.Color c)
Get the background color of left margin- Parameters:
c
- Color
-
showBorders
public void showBorders(boolean show)
Show borders of margins for edditing- Parameters:
show
- true if shown
-
isBorderShown
public boolean isBorderShown()
is the boarder of margins shown?- Returns:
- true if shown.
-
printGraph
public void printGraph()
Print the canvas
-
setMarginSizeRight
public void setMarginSizeRight(double rightSize)
Set the size of right margin of the global canvas in terms of the ration to the global panel in X- Parameters:
rightSize
- size of the right margin (from 0 to 1)
-
disableDoubleBuffering
public static void disableDoubleBuffering(java.awt.Component c)
-
enableDoubleBuffering
public static void enableDoubleBuffering(java.awt.Component c)
-
getMarginSizeRight
public double getMarginSizeRight()
Get the size of right margin of the global canvas in terms of the ratio to thye global canvas- Returns:
- size of the margin from 0 to 1
-
setMarginSizeLeft
public void setMarginSizeLeft(double leftSize)
Set the size of left margin in term of the ratio to the global panel- Parameters:
leftSize
- size of the margin from 0 to 1
-
getMarginSizeLeft
public double getMarginSizeLeft()
Get the size of left margin terms of the ratio to the main panel- Returns:
- left margin size (from 0 to 1)
-
setMarginSizeBottom
public void setMarginSizeBottom(double bottomSize)
Set size of the bottom margin of global canvas in terms of the ratio to the size of the main panel- Parameters:
bottomSize
- size of the bottom margin from 0 to 1
-
setMarginSizeTop
public void setMarginSizeTop(double topSize)
Set size of the top margin of global canvas in terms of the ratio to the size of the main panel- Parameters:
topSize
- size of the top margin from 0 to 1
-
getMarginSizeBottom
public double getMarginSizeBottom()
Get size of the bottom margin as ratio to the main panel- Returns:
- size of the bottom margin (from 0 to 1)
-
setSizePanel
public void setSizePanel(int Width, int Height)
Set the size of the global panel which keeps the central panel and the margins- Parameters:
Width
- WidthHeight
- Height
-
getMarginSizeTop
public double getMarginSizeTop()
Get size of the top margin of global canvas in terms of ratio to the main panel- Returns:
- size of the top margin (from 0 to 1)
-
componentResized
public void componentResized(java.awt.event.ComponentEvent e)
- Specified by:
componentResized
in interfacejava.awt.event.ComponentListener
-
componentMoved
public void componentMoved(java.awt.event.ComponentEvent e)
- Specified by:
componentMoved
in interfacejava.awt.event.ComponentListener
-
componentShown
public void componentShown(java.awt.event.ComponentEvent e)
- Specified by:
componentShown
in interfacejava.awt.event.ComponentListener
-
componentHidden
public void componentHidden(java.awt.event.ComponentEvent e)
- Specified by:
componentHidden
in interfacejava.awt.event.ComponentListener
-
-
DMelt 3.0 © DataMelt by jWork.ORG