/[fenfire]/fenfire/org/fenfire/view/lava/FenPDFContext.java
ViewVC logotype

Diff of /fenfire/org/fenfire/view/lava/FenPDFContext.java

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.38 by mudyc, Thu Jul 17 16:28:19 2003 UTC revision 1.39 by mudyc, Sat Jul 19 12:55:10 2003 UTC
# Line 88  public class FenPDFContext implements Line 88  public class FenPDFContext implements
88    
89    
90      // current main node nro.      // current main node nro.
     private int CURR = 0;  
91      public void initMainNodes(int count) {      public void initMainNodes(int count) {
92          if (cursorOffset != null &&          
             cursorOffset.length == count) return;  
         cursorOffset = new int[count];  
         accursedColor = new Color[]{ Color.red, Color.blue,  
                                      Color.yellow, Color.white};  
         accursed = new Object[count];  
         for (int i=0; i<count; i++) {  
             cursorOffset[i] = 0;  
         }  
93      }      }
     public void setMainNodeIndex(int index) {  
         CURR = index;  
         if (dbg) p("set current: "+index);  
     }  
   
   
     private Color accursedColor[] = null;  
94    
     private int cursorOffset[] = null;  
     public void setCursorOffset(int offset) { cursorOffset[CURR] = offset; }  
   
     private Object[] accursed = null;  
     public void setAccursed(Object node) {  
         accursed[CURR] = node;  
         cursorOffset[CURR] = 0;  
     }  
   
     public boolean isAccursed(Object node) {  
         for (int i=0; i<accursed.length; i++) {  
             if (accursed[i] == node) return true;  
         }  
         return false;  
     }  
       
95    
96      /** call back from ContextNodeView */      /** call back from ContextNodeView */
97      public void isCurrent(Object node, ContextNodeView nv) {      public void isCurrent(Object node, ContextNodeView nv) {
98          if (isAccursed(node)) {          throw new Error("implementation removed");
             nv.setUnCached();  
         } else {  
             nv.setCached();  
         }  
99      }      }
100    
101      /** call back from RSTText */      /** call back from RSTText */
102      public void isToBePlaced(Object node, TextHandler text) {      public void isToBePlaced(Object node, TextHandler text) {
103          if (dbg) p("n"+node+" == "+accursed[CURR]);          throw new Error("implementation removed");
   
         if (isAccursed(node)) {  
             float count=0;  
             float r = 0, g = 0, b = 0;  
             for (int i=0; i<accursed.length; i++) {  
                 if (accursed[i]==node) {  
                     r += accursedColor[i].getRed();  
                     g += accursedColor[i].getGreen();  
                     b += accursedColor[i].getBlue();  
                     count++;  
                 }  
             }  
             r /= count;  
             g /= count;  
             b /= count;  
             //p("colo: " +r+" "+g+" "+b);  
             text.setColor(new Color(r/255,g/255,b/255));  
             text.setCursorOffset(cursorOffset[CURR]);  
         } else {  
             text.setColor(java.awt.Color.black);  
             text.setCursorOffset(-1);  
         }  
104      }      }
105    
106    
     private boolean cursor = false;  
     private boolean link = false;  
   
107      /** call back from AbstractMainNodeView2D */      /** call back from AbstractMainNodeView2D */
108      public void mainNodeToBeRender(VobScene vs, int into,      public void mainNodeToBeRender(VobScene vs, int into,
109                                     AbstractMainNode2D main)                                     AbstractMainNode2D main)
110      {      {
111          // first set everything to false          throw new Error("implementation removed");
         cursor = false;  
         link = false;  
   
         // if in canvas  
         if (main instanceof MainNode2D) {  
             // what to do if accursed is NULL?  
             if (accursed[CURR]==null) {  
                 if (main instanceof MainNode2D)  
                     cursor = true;  
                 // fishey doesn't need cursor (currently)  
             }  
             if (accursed.length >= 2) {  
                 if (accursed[0] != accursed[1] &&  
                     accursed[0] != null &&  
                     accursed[1] != null) link = true;  
             }  
         }  
           
         //render!  
         renderMain(vs, into, main);  
     }  
   
     private void renderMain(VobScene vs, int into,  
                                AbstractMainNode2D main)  
     {  
         if (cursor) {  
             float tmp[] = new float[2];  
             vs.coords.getSqSize(into, tmp);  
             int cursor = vs.orthoBoxCS(into, "CURSOR", 0,  
                                        tmp[0]/2, tmp[1]/2, 1,1, tmp[0]/12, tmp[1]/12);  
             vs.put(new LineVob(0,0,0,1, java.awt.Color.darkGray), cursor);  
         }  
112      }      }
113    
114      public void renderContext(VobScene vs, int into)      public void renderContext(VobScene vs, int into)
115      {      {
116          Button b = new Button(vs, 0, 30, 0, 50);          throw new Error("implementation removed");
         b.add("[Import PS/PDF]", "IMPORT");  
         b.add("[New paper]",     "NEW_PAPER");  
         if (link) b.add("[Link!]", "LINK");  
         b.add("[Save]", "SAVE");  
         b.add("[Load]", "LOAD");  
117      }      }
118    
119    
# Line 260  public class FenPDFContext implements Line 162  public class FenPDFContext implements
162                  return mainNodes;                  return mainNodes;
163              }              }
164              else if (key.equals("LINK")) {              else if (key.equals("LINK")) {
165                  if (CURR >0) actionLink(1); else actionLink(-1);                  ;
166              }              }
167              else if (key.equals("NEW_PAPER")) {              else if (key.equals("NEW_PAPER")) {
168                  String paper = ppAct.newPaper();                  String paper = ppAct.newPaper();
169                  mainNodes[CURR] = new MainNode2D(Nodes.get(paper),                  mainNodes[0] = new MainNode2D(Nodes.get(paper),
170                                                  ppView, new MainNode2D.SimpleFocus(0,0),1,                                                  ppView, new MainNode2D.SimpleFocus(0,0),1,
171                                                   controller);                                                   controller);
172                  return mainNodes;                  return mainNodes;
# Line 289  public class FenPDFContext implements Line 191  public class FenPDFContext implements
191                  //fen.graph.rm_1AA(SAVE.State);                  //fen.graph.rm_1AA(SAVE.State);
192                  p("rm all worked out");                  p("rm all worked out");
193                  for (int i=0; i<mainNodes.length; i++) {                  for (int i=0; i<mainNodes.length; i++) {
                     p("accursed: " + accursed[i]+  
                       "\n  main:"+mainNodes[i]+  
                       "\n  plane: "+ mainNodes[i].getPlane());  
194    
195                      //if (accursed[i] == null) continue;                      //if (accursed[i] == null) continue;
196                      fen.graph.add(SAVE.State, SAVE.point,                      fen.graph.add(SAVE.State, SAVE.point,
# Line 347  public class FenPDFContext implements Line 246  public class FenPDFContext implements
246          return null;          return null;
247      }      }
248    
     private void actionLinkLeft() { actionLink(-1); }  
     private void actionLinkRigth() { actionLink(1); }  
     private void actionLink(int side) {  
         { try {  
             if (side < 0) {  
                 ppAct.assocNotes(Nodes.toString(accursed[0]), -1,  
                                  Nodes.toString(accursed[1]));  
             } else {  
                 ppAct.assocNotes(Nodes.toString(accursed[0]), 1,  
                                  Nodes.toString(accursed[1]));  
             }  
         } catch (Exception e) {  
             p("exception - do nothing.."+e);  
         }}  
     }  
249    
250    
251      public void handleKeyStroke(String s, AbstractMainNode2D main) {      public void handleKeyStroke(String s, AbstractMainNode2D main) {

Legend:
Removed from v.1.38  
changed lines
  Added in v.1.39

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26