Back to index

wims  3.65+svn20090927
Public Member Functions | Package Attributes | Static Package Attributes
WIMSchem.TemplateSelector Class Reference
Inheritance diagram for WIMSchem.TemplateSelector:
Inheritance graph
[legend]
Collaboration diagram for WIMSchem.TemplateSelector:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 TemplateSelector (Templates templ, TemplSelectListener listen, int HeightFudge)
void windowGainedFocus (WindowEvent e)
void windowLostFocus (WindowEvent e)
void MolSelected (EditorPane source, int idx, boolean dblclick)
void DirtyChanged (boolean isdirty)
void actionPerformed (ActionEvent e)

Package Attributes

Templates templ
TemplSelectListener selectListen
EditorPane[] pics = new EditorPane[NUM_WIDGETS]
BasicArrowButton prev
BasicArrowButton next
int curPage = 0
int numPages

Static Package Attributes

static final int MOL_COL = 5
static final int MOL_ROW = 4
static final int MOL_WIDTH = 100
static final int MOL_HEIGHT = 75
static final int FRAME_SIZE = 1
static final int ARROW_WIDTH = 30
static final int ARROW_HEIGHT = 15
static final int WIDTH = MOL_COL*MOL_WIDTH+2*FRAME_SIZE
static final int HEIGHT = MOL_ROW*MOL_HEIGHT+2*FRAME_SIZE+ARROW_HEIGHT
static final int NUM_WIDGETS = MOL_COL*MOL_ROW

Detailed Description

Definition at line 23 of file TemplateSelector.java.


Constructor & Destructor Documentation

WIMSchem.TemplateSelector.TemplateSelector ( Templates  templ,
TemplSelectListener  listen,
int  HeightFudge 
) [inline]

Definition at line 39 of file TemplateSelector.java.

    {
       this.templ=templ;
       selectListen=listen;
       
       setUndecorated(true);
       getRootPane().setWindowDecorationStyle(JRootPane.NONE);
       setSize(WIDTH,HEIGHT+HeightFudge);
       
       TemplateBorder content=new TemplateBorder();
       setContentPane(content);

       Color bckgr=getBackground();
       Color shade1=new Color(Math.max(bckgr.getRed()-8,0),Math.max(bckgr.getGreen()-8,0),bckgr.getBlue());
       Color shade2=new Color(Math.max(bckgr.getRed()-16,0),Math.max(bckgr.getGreen()-16,0),bckgr.getBlue());
       content.setBackground(shade1);
       
       for (int n=0;n<NUM_WIDGETS;n++) if (n<templ.NumTemplates())
       {
           pics[n]=new EditorPane(MOL_WIDTH,MOL_HEIGHT);
           pics[n].SetEditable(false);
           pics[n].setBackground(shade1);
           pics[n].Replace(templ.GetTemplate(n));
           pics[n].ScaleToFit();
           content.add(pics[n]);
           pics[n].setLocation(FRAME_SIZE+MOL_WIDTH*(n%MOL_COL),FRAME_SIZE+MOL_HEIGHT*(n/MOL_COL));
           pics[n].SetToolCursor();
           pics[n].SetMolSelectListener(this);
       }
       numPages=(int)Math.ceil(templ.NumTemplates()/(double)NUM_WIDGETS);
       
       prev=new BasicArrowButton(SwingConstants.WEST);
       next=new BasicArrowButton(SwingConstants.EAST);
       content.add(prev);
       content.add(next);
       prev.setLocation(WIDTH-FRAME_SIZE-2*ARROW_WIDTH,HEIGHT-FRAME_SIZE-ARROW_HEIGHT);
       prev.setSize(ARROW_WIDTH,ARROW_HEIGHT);
       next.setLocation(WIDTH-FRAME_SIZE-ARROW_WIDTH,HEIGHT-FRAME_SIZE-ARROW_HEIGHT);
       next.setSize(ARROW_WIDTH,ARROW_HEIGHT);
       prev.addActionListener(this);
       next.addActionListener(this);
       
       addWindowFocusListener(this);
    }

Here is the call graph for this function:


Member Function Documentation

void WIMSchem.TemplateSelector.actionPerformed ( ActionEvent  e) [inline]

Definition at line 100 of file TemplateSelector.java.

    {
       int newPage=curPage;
       if (e.getSource()==prev) newPage=curPage>0 ? curPage-1 : numPages-1;
       if (e.getSource()==next) newPage=curPage<numPages-1 ? curPage+1 : 0;
       if (newPage!=curPage)
       {
           curPage=newPage;
           
           for (int n=0;n<NUM_WIDGETS;n++)
           {
              int i=curPage*NUM_WIDGETS+n;
              pics[n].Replace(i<templ.NumTemplates() ? templ.GetTemplate(i) : new Molecule());
              pics[n].ScaleToFit();
           }
       }
    }

Here is the call graph for this function:

void WIMSchem.TemplateSelector.DirtyChanged ( boolean  isdirty) [inline]

Implements WIMSchem.MolSelectListener.

Definition at line 98 of file TemplateSelector.java.

{}
void WIMSchem.TemplateSelector.MolSelected ( EditorPane  source,
int  idx,
boolean  dblclick 
) [inline]

Implements WIMSchem.MolSelectListener.

Definition at line 92 of file TemplateSelector.java.

    {
       if (idx==0) return;
       selectListen.TemplSelected(source.MolData().Clone(),idx);
       dispose();
    }

Here is the call graph for this function:

void WIMSchem.TemplateSelector.windowGainedFocus ( WindowEvent  e) [inline]

Definition at line 86 of file TemplateSelector.java.

{}
void WIMSchem.TemplateSelector.windowLostFocus ( WindowEvent  e) [inline]

Definition at line 87 of file TemplateSelector.java.

    {
       dispose();
    }

Member Data Documentation

final int WIMSchem.TemplateSelector.ARROW_HEIGHT = 15 [static, package]

Definition at line 30 of file TemplateSelector.java.

final int WIMSchem.TemplateSelector.ARROW_WIDTH = 30 [static, package]

Definition at line 30 of file TemplateSelector.java.

Definition at line 37 of file TemplateSelector.java.

final int WIMSchem.TemplateSelector.FRAME_SIZE = 1 [static, package]

Definition at line 29 of file TemplateSelector.java.

Definition at line 32 of file TemplateSelector.java.

final int WIMSchem.TemplateSelector.MOL_COL = 5 [static, package]

Definition at line 28 of file TemplateSelector.java.

final int WIMSchem.TemplateSelector.MOL_HEIGHT = 75 [static, package]

Definition at line 28 of file TemplateSelector.java.

final int WIMSchem.TemplateSelector.MOL_ROW = 4 [static, package]

Definition at line 28 of file TemplateSelector.java.

final int WIMSchem.TemplateSelector.MOL_WIDTH = 100 [static, package]

Definition at line 28 of file TemplateSelector.java.

BasicArrowButton WIMSchem.TemplateSelector.next [package]

Definition at line 36 of file TemplateSelector.java.

final int WIMSchem.TemplateSelector.NUM_WIDGETS = MOL_COL*MOL_ROW [static, package]

Definition at line 33 of file TemplateSelector.java.

Definition at line 37 of file TemplateSelector.java.

Definition at line 35 of file TemplateSelector.java.

BasicArrowButton WIMSchem.TemplateSelector.prev [package]

Definition at line 36 of file TemplateSelector.java.

Definition at line 26 of file TemplateSelector.java.

Definition at line 25 of file TemplateSelector.java.

Definition at line 31 of file TemplateSelector.java.


The documentation for this class was generated from the following file: