/* * To change this template, choose Tools | Templates * and open the template in the editor. */ package eric.GUI.palette; import eric.GUI.window.LeftPanel; import eric.GUI.window.MenuBar; import eric.GUI.window.RightPanel; import eric.JZirkelCanvas; import eric.macros.MacroTools; import eric.restrict.RestrictItems; import eric.restrict.RestrictPanel; import java.awt.Color; import java.awt.Dimension; import java.util.ArrayList; import javax.swing.JComponent; import javax.swing.SwingUtilities; import rene.gui.Global; import rene.zirkel.ZirkelCanvas; import rene.zirkel.construction.Construction; /** * * @author erichake */ public class PaletteManager { private static String GEOM_GROUP="geom"; static String POINT_GROUP="point"; static String ASPECT1_GROUP="aspect1"; static String ASPECT2_GROUP="aspect2"; static String GRID1_GROUP="grid1"; static String GRID2_GROUP="grid2"; static String PHOTO_GROUP="photo"; private static RightPanel MainPanel; private static JIcon ctrlJSlider, ctrlJPopup, ctrlJCheckBox, ctrlJTextField, ctrlJButton; private static ArrayList allIcons=new ArrayList(); private static PaletteZone JPDisk, JPEdit, JPfunc, JPTest, JPControls, JPHist, JPSizes, JPColors, JPPrec, JPGrid; private static ArrayList PaletteWithIconOnly; private static PaletteZone_Aspect JPAspect; private static PaletteZone_Geom JPGeom; private static PaletteZone_3D JP3D; private static JColorPanel colorpanel; public static ArrayList getAllIcons() { return allIcons; } public static void fixsize(JComponent jc, int w, int h) { Dimension d=new Dimension(w, h); jc.setSize(d); jc.setMaximumSize(d); jc.setMinimumSize(d); jc.setPreferredSize(d); } public static void construct(RightPanel mainpanel) { MainPanel=mainpanel; MainPanel.removeAll(); allIcons.clear(); constructJPDisk(); constructJPEdit(); constructJP3D(); constructJPGeom(); constructJPAspect(); constructJPfunc(); constructJPTest(); constructJPControls(); constructJPGrid(); constructJPHist(); constructJPColors(); constructJPSizes(); constructJPPrec(); setDefault(); PaletteWithIconOnly=new ArrayList(); PaletteWithIconOnly.add(JPDisk); PaletteWithIconOnly.add(JPEdit); PaletteWithIconOnly.add(JP3D); PaletteWithIconOnly.add(JPGeom); PaletteWithIconOnly.add(JPfunc); PaletteWithIconOnly.add(JPTest); PaletteWithIconOnly.add(JPControls); } public static void init() { if (RightPanel.isPanelVisible()) { fixRestrictedEnvironment(); JPDisk.init(); JPEdit.init(); // JPDP.init(); JP3D.init(); JPGeom.init(); JPAspect.init(); JPfunc.init(); JPTest.init(); JPControls.init(); JPGrid.init(); JPHist.init(); JPColors.init(); JPSizes.init(); JPPrec.init(); FixPaletteHeight(null); } } private static void setDefault() { setSelected_with_clic("type"+Global.getParameter("options.type", 0), true); setSelected_with_clic("obtuse", Global.getParameter("options.obtuse", true)); } public static boolean isPaletteWithIconOnly(PaletteZone pz) { for (int i=0; i=0)&&(lastpz.getBounds().y+lastpz.getBounds().height>MainPanel.getBounds().height)) { PaletteZone pz=(PaletteZone) MainPanel.getComponent(i); if (!pz.equals(caller)) { pz.setHideContent(true); pz.init(); MainPanel.validate(); } i--; } } MainPanel.repaint(); } public static void FixPaletteHeight2(PaletteZone caller) { if (caller!=null) { caller.init(); } MainPanel.validate(); if (MainPanel.getComponentCount()!=0) { int i=MainPanel.getComponentCount()-1; PaletteZone lastpz=(PaletteZone) MainPanel.getComponent(i); while ((i>=0)&&(lastpz.getBounds().y+lastpz.getBounds().height>MainPanel.getBounds().height)) { PaletteZone pz=(PaletteZone) MainPanel.getComponent(i); if (!pz.equals(caller)&&!pz.equals(JPGeom)&&!pz.equals(JPAspect)&&!pz.equals(JPEdit)) { pz.setHideContent(true); pz.init(); MainPanel.validate(); } i--; } } MainPanel.repaint(); } public static void registerIcon(JIcon icn) { allIcons.add(icn); } public static void removeIcon(JIcon icn) { allIcons.remove(icn); } public static void setOverBtn(JIcon icn) { icn.setOver(true); for (int i=0; i