Make first real commit: copy of CaRMetal 4.2.8

This commit is contained in:
Glen Whitney 2018-09-04 22:51:42 -04:00
parent 002acfc88e
commit c312811084
1120 changed files with 226843 additions and 1 deletions

BIN
eric/GUI/palette/.DS_Store vendored Normal file

Binary file not shown.

View file

@ -0,0 +1,358 @@
/*
Copyright 2006 Eric Hakenholz
This file is part of C.a.R. software.
C.a.R. is a free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, version 3 of the License.
C.a.R. is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package eric.GUI.palette;
import eric.GUI.themes;
import eric.JZirkelCanvas;
import java.awt.BasicStroke;
import java.awt.Color;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.Graphics2D;
import java.awt.Image;
import java.awt.Stroke;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.awt.event.MouseMotionListener;
import java.awt.image.BufferedImage;
import javax.swing.BoxLayout;
import javax.swing.JComboBox;
import javax.swing.JComponent;
import javax.swing.JDialog;
import javax.swing.JLabel;
import eric.JEricPanel;
import javax.swing.SwingConstants;
import net.java.dev.colorchooser.ColorChooser;
import net.java.dev.colorchooser.Palette;
import rene.gui.Global;
/**
*
* @author erichake
*/
public class JColorPanel extends JEricPanel implements MouseListener,
MouseMotionListener {
/**
*
*/
private final ColorChooser cchooser;
private Palette Pal;
int PaletteType;
int xx, yy;
colorline mycolorpickerline;
JComboBox JCB;
JLabel comment;
JColorPanel me;
/**
*
* @param g
*/
@Override
public void paintComponent(final java.awt.Graphics g) {
super.paintComponent(g);
final java.awt.Dimension d=this.getSize();
g.drawImage(themes.getImage("palbackground.gif"), 0, 0, d.width,
d.height, this);
}
/**
* Creates a new instance of JColorPanel
*
* @param zf
* @param jpm
*/
public JColorPanel() {
me=this;
xx=-1;
yy=-1;
PaletteType=Global.getParameter("colorbackgroundPal", 1);
cchooser=new ColorChooser();
this.setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
this.setAlignmentX(0);
this.setOpaque(false);
this.add(margintop(5));
JCB=new JComboBox();
JCB.setMaximumRowCount(5);
JCB.setOpaque(false);
JCB.setFocusable(false);
JCB.setEditable(false);
JCB.setAlignmentX(0);
JCB.setFont(new Font("System", 0, 11));
JCB.addItem(Global.Loc("palette.colors.saturated1"));
JCB.addItem(Global.Loc("palette.colors.desaturated1"));
JCB.addItem(Global.Loc("palette.colors.saturated2"));
JCB.addItem(Global.Loc("palette.colors.desaturated2"));
JCB.addItem(Global.Loc("palette.colors.constants"));
JCB.setSelectedIndex(PaletteType);
JCB.addItemListener(new ItemAdapter());
final JEricPanel JCBpanel=new JEricPanel();
JCBpanel.setLayout(new BoxLayout(JCBpanel, BoxLayout.X_AXIS));
JCBpanel.setAlignmentX(0);
JCBpanel.setOpaque(false);
fixsize(JCBpanel, themes.getRightPanelWidth(), 24);
JCBpanel.add(margin(5));
fixsize(JCB, themes.getRightPanelWidth()-10, 22);
JCBpanel.add(JCB);
this.add(JCBpanel);
mycolorpickerline=new colorline(PaletteType);
this.add(mycolorpickerline);
comment=new JLabel("coucou");
comment.setOpaque(false);
comment.setAlignmentX(0);
comment.setFont(new Font("System", 0, 9));
fixsize(comment, themes.getRightPanelWidth(), 14);
comment.setHorizontalAlignment(SwingConstants.CENTER);
this.add(comment);
}
public void refresh(){
JCB.setSelectedIndex(Global.getParameter("colorbackgroundPal", 1));
}
class ItemAdapter implements ItemListener {
public void itemStateChanged(final ItemEvent evt) {
if (evt.getStateChange()==ItemEvent.SELECTED) {
me.remove(mycolorpickerline);
mycolorpickerline=new colorline(JCB.getSelectedIndex());
Global.setParameter("colorbackgroundPal", JCB.getSelectedIndex());
me.add(mycolorpickerline, 2);
int x=Global.getParameter("colorbackgroundx", 74);
int y=Global.getParameter("colorbackgroundy", 12);
x=x*Pal.getSize().width/mycolorpickerline.mycolors.getSize().width;
y=y*Pal.getSize().height/mycolorpickerline.mycolors.getSize().height;
final Color mycolor=Pal.getColorAt(x, y);
if (mycolor!=null) {
Global.setParameter("colorbackground", mycolor);
}
me.repaint();
PaletteManager.init();
}
}
}
public JDialog GetDialog(final Component c) {
if (c instanceof JDialog||null==c) {
return c==null?null:(JDialog) c;
}
return GetDialog(c.getParent());
}
class colorline extends JEricPanel {
/**
*
*/
JEricPanel mymargin;
onlycolors mycolors;
colorline(final int ptype) {
PaletteType=ptype;
Pal=cchooser.getPalettes()[ptype];
this.setLayout(new BoxLayout(this, BoxLayout.X_AXIS));
this.setAlignmentX(0);
mymargin=margin(0);
if (themes.getRightPanelWidth()>Pal.getSize().width) {
fixsize(mymargin, (themes.getRightPanelWidth()-Pal.getSize().width)/2, 1);
}
this.add(mymargin);
mycolors=new onlycolors(ptype);
this.add(mycolors);
this.setOpaque(false);
}
// public void fixmargin(){
// if (PW>Pal.getSize().width){
// fixsize(mymargin,(PW-Pal.getSize().width)/2,1);
// }
// }
// public void setPalette(int i){
// mycolors.changePal(i);
// fixmargin();
// }
}
private class onlycolors extends JEricPanel {
/**
*
*/
Image bimage;
@Override
public void paintComponent(final java.awt.Graphics g) {
super.paintComponent(g);
final Dimension d=this.getSize();
final int w=d.width;
final int h=d.height;
g.drawImage(bimage, 0, 0, w, h, this);
final Color mycolor=Global.getParameter("colorbackground",
new Color(231, 238, 255));
cchooser.setColor(mycolor);
if (JZirkelCanvas.getCurrentZC()!=null) {
JZirkelCanvas.getCurrentZC().setBackground(mycolor);
JZirkelCanvas.getCurrentZC().repaint();
}
int x=Global.getParameter("colorbackgroundx", 74);
int y=Global.getParameter("colorbackgroundy", 12);
if (PaletteType==4) {
x=((int) (x/12))*12+6;
y=((int) (y/12))*12+6;
}
final Graphics2D g2=(Graphics2D) g;
// AlphaComposite ac =
// AlphaComposite.getInstance(AlphaComposite.SRC_OVER,0.5f);
// g2.setComposite(ac);
g2.setColor(new Color(0, 0, 0));
Stroke stroke=new BasicStroke(1f);
g2.setStroke(stroke);
g2.drawRect(x-4, y-4, 8, 8);
stroke=new BasicStroke(1f);
g2.setStroke(stroke);
g2.setColor(new Color(255, 255, 255));
g2.drawRect(x-3, y-3, 6, 6);
// g.drawRect(x-5,y-5,10,10);
comment.setText(Pal.getNameAt(x, y));
}
onlycolors(final int ptype) {
final int w=(themes.getRightPanelWidth()<Pal.getSize().width)?themes.getRightPanelWidth():Pal.getSize().width;
fixsize(this, w, Pal.getSize().height);
bimage=new BufferedImage(Pal.getSize().width,Pal.getSize().height, BufferedImage.TYPE_INT_RGB);
Pal.paintTo(bimage.getGraphics());
this.setLayout(new BoxLayout(this, BoxLayout.X_AXIS));
this.setAlignmentX(0);
this.setOpaque(false);
this.addMouseMotionListener(me);
this.addMouseListener(me);
}
// public void changePal(int i){
//
// Pal=cchooser.getPalettes()[i];
// int w=(PW<Pal.getSize().width)?PW:Pal.getSize().width;
// fixsize(this,w,Pal.getSize().height);
// bimage=JPM.MW.createImage(Pal.getSize().width,Pal.getSize().height);
// Pal.paintTo(bimage.getGraphics());
// }
}
private void fixsize(final JComponent cp, final int w, final int h) {
final Dimension d=new Dimension(w, h);
cp.setMaximumSize(d);
cp.setMinimumSize(d);
cp.setPreferredSize(d);
cp.setSize(d);
}
private JEricPanel margin(final int w) {
final JEricPanel mypan=new JEricPanel();
fixsize(mypan, w, 1);
mypan.setOpaque(false);
mypan.setFocusable(false);
return mypan;
}
private JEricPanel margintop(final int h) {
final JEricPanel mypan=new JEricPanel();
fixsize(mypan, 1, h);
mypan.setOpaque(false);
mypan.setFocusable(false);
return mypan;
}
public void mouseClicked(final MouseEvent e) {
}
public void mousePressed(final MouseEvent e) {
int x=e.getX();
int y=e.getY();
if (e.isShiftDown()) {
if (yy==-1) {
yy=y;
}
y=yy;
}
if (e.isAltDown()) {
if (xx==-1) {
xx=x;
}
x=xx;
}
if (x>mycolorpickerline.mycolors.getSize().width) {
x=mycolorpickerline.mycolors.getSize().width;
}
if (x<0) {
x=0;
}
if (y>mycolorpickerline.mycolors.getSize().height) {
y=mycolorpickerline.mycolors.getSize().height;
}
if (y<0) {
y=0;
}
Global.setParameter("colorbackgroundx", x);
Global.setParameter("colorbackgroundy", y);
x=x*Pal.getSize().width/mycolorpickerline.mycolors.getSize().width;
y=y*Pal.getSize().height/mycolorpickerline.mycolors.getSize().height;
final Color mycolor=Pal.getColorAt(x, y);
if (mycolor!=null) {
Global.setParameter("colorbackground", mycolor);
JZirkelCanvas.getCurrentLocalPreferences();
mycolorpickerline.mycolors.repaint();
}
}
public void mouseReleased(final MouseEvent e) {
xx=-1;
yy=-1;
}
public void mouseEntered(final MouseEvent e) {
}
public void mouseExited(final MouseEvent e) {
}
public void mouseDragged(final MouseEvent e) {
mousePressed(e);
}
public void mouseMoved(final MouseEvent e) {
}
}

View file

@ -0,0 +1,132 @@
/*
Copyright 2006 Eric Hakenholz
This file is part of C.a.R. software.
C.a.R. is a free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, version 3 of the License.
C.a.R. is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package eric.GUI.palette;
import eric.*;
import eric.GUI.themes;
import java.awt.Color;
import java.awt.Font;
import javax.swing.BoxLayout;
import javax.swing.JLabel;
import eric.JEricPanel;
import javax.swing.JSlider;
import rene.gui.Global;
/**
*
* @author erichake
*/
public class JCursor extends JEricPanel {
/**
*
*/
private static final long serialVersionUID = 1L;
JLabel mylabel, myval;
public JSlider mycursor;
String myP, mytxt;
boolean palmember = false;
/** Creates a new instance of JCursor */
@Override
public void paintComponent(final java.awt.Graphics g) {
super.paintComponent(g);
if (palmember) {
final java.awt.Dimension d = this.getSize();
g.drawImage(themes.getImage("palbackground.gif"), 0, 0,
d.width, d.height, this);
}
}
// JCursor constructor for palette member :
public JCursor(final String myparam, final String mytext, final int min,
final int max, int sel) {
sel = Global.getParameter(myparam, sel);
myP = myparam;
palmember = true;
final int lblwidth = 65;
mytxt = mytext;
mycursor = new JSlider();
mylabel = new JLabel();
myval = new JLabel();
this.setLayout(new BoxLayout(this, BoxLayout.X_AXIS));
this.setAlignmentX(0);
mylabel.setText(" " + mytxt);
mylabel.setForeground(Color.DARK_GRAY);
mylabel.setFont(new Font(Global.GlobalFont, Font.PLAIN, 11));
mylabel.setSize(lblwidth, 27);
mylabel.setMaximumSize(new java.awt.Dimension(lblwidth, 27));
mylabel.setMinimumSize(new java.awt.Dimension(lblwidth, 27));
mylabel.setPreferredSize(new java.awt.Dimension(lblwidth, 27));
myval.setText(String.valueOf(sel));
myval.setForeground(Color.GRAY);
myval.setFont(new java.awt.Font(Global.GlobalFont, Font.BOLD, 11));
myval.setSize(20, 27);
myval.setMaximumSize(new java.awt.Dimension(20, 27));
myval.setMinimumSize(new java.awt.Dimension(20, 27));
myval.setPreferredSize(new java.awt.Dimension(20, 27));
mycursor.setFont(new java.awt.Font(Global.GlobalFont, 0, 11));
mycursor.setOpaque(false);
mycursor.setMajorTickSpacing(1);
mycursor.setMaximum(max);
mycursor.setMinimum(min);
mycursor.setMinorTickSpacing(1);
mycursor.setPaintLabels(false);
mycursor.setPaintTicks(false);
mycursor.setSnapToTicks(true);
mycursor.setValue(sel);
mycursor.setAlignmentX(0.0F);
mycursor.setMaximumSize(new java.awt.Dimension(themes.getRightPanelWidth() - 82, 27));
mycursor.setMinimumSize(new java.awt.Dimension(themes.getRightPanelWidth() - 82, 27));
mycursor.setPreferredSize(new java.awt.Dimension(themes.getRightPanelWidth() - 82, 27));
mycursor.setSize(new java.awt.Dimension(themes.getRightPanelWidth() - 82, 27));
mycursor.addChangeListener(new javax.swing.event.ChangeListener() {
public void stateChanged(final javax.swing.event.ChangeEvent evt) {
final JSlider myc = (JSlider) evt.getSource();
final int mysel = myc.getValue();
rene.gui.Global.setParameter(myP, mysel);
// JPM.MW.JPR.getLocalPreferences();
if (JZirkelCanvas.getCurrentZC()!=null) {
JZirkelCanvas.getCurrentZC().getLocalPreferences();
JZirkelCanvas.getCurrentZC().updateDigits();
JZirkelCanvas.getCurrentZC().JCM.updateDigits();
JZirkelCanvas.getCurrentZC().resetGraphics();
JZirkelCanvas.getCurrentZC().repaint();
};
myval.setText(String.valueOf(mysel));
}
});
this.add(mylabel);
this.add(mycursor);
this.add(myval);
this.setOpaque(false);
this.setMaximumSize(new java.awt.Dimension(themes.getRightPanelWidth(), 27));
this.setMinimumSize(new java.awt.Dimension(themes.getRightPanelWidth(), 27));
this.setPreferredSize(new java.awt.Dimension(themes.getRightPanelWidth(), 27));
this.setSize(themes.getRightPanelWidth(), 27);
}
}

611
eric/GUI/palette/JIcon.java Normal file
View file

@ -0,0 +1,611 @@
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package eric.GUI.palette;
import eric.FileTools;
import eric.GUI.pipe_tools;
import eric.GUI.themes;
import eric.GUI.window.LeftPanel;
import eric.GUI.window.tab_main_panel;
import java.awt.image.ImageFilter;
import eric.GUI.windowComponent;
import eric.JZirkelCanvas;
import eric.macros.CreateMacroDialog;
import eric.macros.MacroTools;
import java.awt.AlphaComposite;
import java.awt.BasicStroke;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Graphics2D;
import java.awt.Image;
import java.awt.Point;
import java.awt.Stroke;
import java.awt.event.MouseEvent;
import java.awt.image.FilteredImageSource;
import javax.swing.GrayFilter;
import javax.swing.ImageIcon;
import rene.gui.Global;
import rene.zirkel.ZirkelCanvas;
import rene.zirkel.ZirkelFrame;
import rene.zirkel.constructors.AreaConstructor;
import rene.zirkel.constructors.QuadricConstructor;
import rene.zirkel.tools.JLocusObjectTracker;
import rene.zirkel.tools.JSmacroTool;
import rene.zirkel.tools.ObjectTracker;
/**
*
* @author erichake
*/
public class JIcon extends windowComponent {
// icon_group==null means simple push button
// icon_group==icon_name name means simple toggle button
private String icon_name="";
private String icon_group="";
private boolean isSelected; // icon state
private boolean isDisabled=false; // icon disabled ?
private boolean isEntered=false; // Mouseover ?
private Image image=null;
private int IconsPerRow=-1; // Number of icons per row.
// If -1 then this is the standard number defined
// by themes.palette_icon_per_row
@Override
public void paintComponent(final java.awt.Graphics g) {
super.paintComponent(g);
final java.awt.Dimension d=this.getSize();
final int w=d.width;
final int h=d.height;
final Graphics2D g2=windowComponent.getGraphics2D(g);
if (isDisabled) {
final ImageFilter filter=new GrayFilter(true, 60);
final Image disImage=createImage(new FilteredImageSource(image.getSource(), filter));
final ImageIcon myicn=new ImageIcon(disImage);
g2.drawImage(myicn.getImage(), 0, 0, w, h, this);
return;
}
g2.drawImage(image, 0, 0, w, h, this);
if (isSelected) {
final AlphaComposite ac=AlphaComposite.getInstance(
AlphaComposite.SRC_OVER, 0.2f);
g2.setComposite(ac);
g2.setColor(new Color(0, 0, 100));
// g2.fillRoundRect(1,1,w-1,h-1,14,14);
g2.fillRect(1, 1, w-1, h-1);
}
if (isEntered) {
final AlphaComposite ac=AlphaComposite.getInstance(
AlphaComposite.SRC_OVER, 0.1f);
g2.setComposite(ac);
g2.setColor(new Color(0, 0, 80));
final Stroke stroke=new BasicStroke(3f);
g2.setStroke(stroke);
g2.drawRect(2, 2, w-4, h-4);
}
}
public JIcon(String name, String group) {
super();
icon_name=name;
icon_group=group;
image=themes.getPaletteImage(name);
PaletteManager.registerIcon(this);
String ttp=PaletteManager.ToolTip(name);
if (ttp!=null) {
setToolTipText("<html>"+ttp.replace("+", "<br>")+"</html>");
}
setOpaque(false);
}
public JIcon(String name, String group, int iconperrow) {
this(name, group);
IconsPerRow=iconperrow;
}
public String getIconGroup() {
return icon_group;
}
public String getIconName() {
return icon_name;
}
public boolean isToggleButton() {
return (icon_name.equals(icon_group));
}
public boolean isPushButton() {
return (icon_group==null);
}
public void setOver(boolean b) {
isEntered=b;
}
public void setSelected(boolean b) {
isSelected=b;
}
public void setDisabled(boolean b) {
isDisabled=b;
}
public boolean isSelected() {
return isSelected;
}
public boolean isDisabled() {
return isDisabled;
}
public void init() {
int w=getIconWidth();
setPreferredSize(new Dimension(w, w));
}
public int getIconWidth() {
if (IconsPerRow==-1) {
return themes.getPaletteIconWidth();
} else {
int w=(themes.getPaletteIconPerRow()*themes.getPaletteIconWidth())/IconsPerRow;
return w;
}
}
@Override
public Point getToolTipLocation(MouseEvent event) {
return new Point(getSize().width/2, getSize().height+4);
}
@Override
public void mouseClicked(MouseEvent e) {
}
@Override
public void mousePressed(MouseEvent e) {
ClicOnMe();
}
@Override
public void mouseReleased(MouseEvent e) {
}
@Override
public void mouseEntered(MouseEvent e) {
PaletteManager.setOverBtn(this);
}
@Override
public void mouseExited(MouseEvent e) {
isEntered=false;
PaletteManager.repaint();
}
private static ZirkelFrame ZF;
private static ZirkelCanvas ZC;
private static JZirkelCanvas JZF;
private static String moveonreselect=",delete,hide,rename,edit,zoom,animate,";
private static void TasksBeforeClick(JIcon me) {
ZF.CurrentTool=0;
if (PaletteManager.isGeomGroup(me.getIconName())) {
AreaConstructor.deletePreview(ZF.ZC);
QuadricConstructor.deletePreview(ZF.ZC);
}
CreateMacroDialog.quit();
ZF.ZC.JCM.hideHandles(null);
}
public void ClicOnMe() {
if ((moveonreselect.indexOf(","+icon_name+",")!=-1)&&(isSelected)) {
PaletteManager.setSelected_with_clic("move", true);
return;
}
PaletteManager.setSelectBtn(this);
ZF=JZirkelCanvas.getCurrentZF();
JZF=JZirkelCanvas.getCurrentJZF();
ZC=JZirkelCanvas.getCurrentZC();
if (ZC==null) {
return;
}
if(ZC.getTool() instanceof JSmacroTool){
((JSmacroTool) ZC.getTool()).invalidate(ZC);
}
PaletteManager.setGoodProperties(icon_name);
TasksBeforeClick(this);
action(this, icon_name);
}
private static boolean checkReplay(String o) {
if (o.equals("oneforward")) {
JZF.getReplay().iconPressed(o);
} else if (o.equals("oneback")) {
JZF.getReplay().iconPressed(o);
} else if (o.equals("fastforward")) {
JZF.getReplay().iconPressed(o);
} else if (o.equals("fastback")) {
JZF.getReplay().iconPressed(o);
} else if (o.equals("allforward")) {
JZF.getReplay().iconPressed(o);
} else if (o.equals("setbreak")) {
JZF.getReplay().iconPressed(o);
} else if (o.equals("nextbreak")) {
JZF.getReplay().iconPressed(o);
} else {
JZF.getReplay().doclose();
return false;
}
return true;
}
private static void action(JIcon me, String o) {
if (checkReplay(o)) {
return;
}
if (me.isDisabled) {
return;
}
ZC.pause(true);
ZC.requestFocus();
ZF.setinfo(o);
if ((ZC.isDP())&&(!ZC.isEuclidian())&&(MacroTools.isDPMacro(o))) {
MacroTools.runDPMacro(o);
} else if (o.equals("select")) {
ZF.ZC.setSelectTool();
} else if (o.equals("load")) {
ZF.setinfo("save");
FileTools.openFile();
} else if (o.equals("save")) {
ZF.setinfo("save");
FileTools.saveFile();
} else if (o.equals("new")) {
tab_main_panel.newTabBtn();
pipe_tools.actualiseMacroPanel();
} else if (o.equals("newmacro")) {
new CreateMacroDialog(JZirkelCanvas.getNewMacroPanel());
JZirkelCanvas.ActualiseMacroPanel();
} else if (o.equals("manage_macros")) {
LeftPanel.showPanel(me.isSelected);
} else if (o.startsWith("type")) {
ZF.settype(Integer.parseInt(o.substring(4)));
ZF.setinfo("zone_aspect");
} else if (o.startsWith("thickness")) {
setObjectColorType(Integer.parseInt(o.substring(9)));
ZF.setinfo("zone_aspect");
} else if (o.startsWith("filled")) {
setObjectFilled(me.isSelected);
} else if (o.startsWith("color")) {
ZF.setinfo("zone_aspect");
setObjectColor(Integer.parseInt(o.substring(5)));
} else if (o.startsWith("acolor")) {
final int chx=Integer.parseInt(o.substring(6));
ZF.ZC.setAxis_color(chx);
ZF.ZC.repaint();
} else if (o.startsWith("athickness")) {
final int chx=Integer.parseInt(o.substring(10));
ZF.ZC.setAxis_thickness(chx);
ZF.ZC.repaint();
} else if (o.equals("numgrid")) {
ZF.ZC.setAxis_labels(me.isSelected);
ZF.ZC.repaint();
} else if (o.equals("dottedgrid")) {
ZF.ZC.setAxis_with_grid(me.isSelected);
ZF.ZC.repaint();
} else if (o.equals("vector")) {
//ZF.setVectors(true);
ZF.settool("vector");
} else if (o.equals("vector3D")) {
//ZF.setVectors(true);
ZF.settool("vector");
} else if (o.equals("inter3D")) {
//ZF.setVectors(true);
ZF.settool("intersection");
} else if (o.equals("midpoint3D")) {
//ZF.setVectors(true);
ZF.settool("midpoint");
} else if (o.equals("segment3D")) {
//ZF.setVectors(true);
ZF.settool("segment");
} else if (o.equals("line3D")) {
//ZF.setVectors(true);
ZF.settool("line");
} else if (o.equals("ray3D")) {
//ZF.setVectors(true);
ZF.settool("ray");
} else if (o.equals("area3D")) {
//ZF.setVectors(true);
ZF.settool("area");
} else if (o.equals("segment")) {
//ZF.setVectors(false);
ZF.settool("segment");
} else if (o.equals("quadric")) {
//ZF.setVectors(false);
ZF.settool("quadric");
} else if (o.equals("fixedsegment")) {
ZF.setVectors(false);
ZF.settool("fixedsegment");
} else if (o.equals("angle3D")) {
//ZF.setVectors(true);
ZF.settool("angle");
} else if (o.equals("image3")) {
ZF.settool("image");
// if (!ZF.haveFile()) {
// JOptionPane.showMessageDialog(null, Global.Loc("palette.image.fileerror"));
//// PaletteManager.MW.savefile();
// }
//
// if (ZF.haveFile()) {
// ZF.settool("image");
// } else {
// PaletteManager.setSelected("point", true);
// }
} else if (o.equals("background")) {
ZF.setinfo("background");
if (me.isSelected) {
Global.setParameter("background.usesize",
false);
Global.setParameter("background.tile",
false);
Global.setParameter("background.center",
true);
ZF.loadBackground();
PaletteManager.setSelected_with_clic("imcenter", true);
} else {
ZF.ZC.grab(false);
}
} else if (o.equals("imcenter")) {
rene.gui.Global.setParameter("background.usesize", false);
rene.gui.Global.setParameter("background.tile", false);
rene.gui.Global.setParameter("background.center", true);
ZF.setinfo("background");
ZF.ZC.repaint();
} else if (o.equals("imtile")) {
rene.gui.Global.setParameter("background.usesize", false);
rene.gui.Global.setParameter("background.tile", true);
rene.gui.Global.setParameter("background.center", false);
ZF.setinfo("background");
ZF.ZC.repaint();
} else if (o.equals("imstretch")) {
rene.gui.Global.setParameter("background.usesize", true);
rene.gui.Global.setParameter("background.tile", false);
rene.gui.Global.setParameter("background.center", false);
ZF.setinfo("background");
ZF.ZC.repaint();
// } else if (name.equals("loadmacros")) {
// JMacrosTools.OpenMacro("");
// } else if (name.equals("new")) {
// JMacrosTools.NewWindow();
// } else if (name.equals("load")) {
// JMacrosTools.OpenFile();
// } else if (name.equals("save")) {
// PaletteManager.MW.savefile();
} else if (o.equals("allback")) {
// ZF.settool(ZF.NParameters);
JZF.disposeReplay();
JZF.newReplay();
JZF.getReplay().iconPressed(o);
} else if (o.equals("partial")) {
ZF.ZC.setPartial(me.isSelected);
} else if (o.equals("plines")) {
ZF.ZC.setPartialLines(me.isSelected);
} else if (o.equals("showvalue")) {
setObjectShowValue(me.isSelected);
} else if (o.equals("hidden")) {
ZF.sethidden(me.isSelected);
ZC.reloadCD();
ZF.setinfo("hidden");
} else if (o.equals("showname")) {
setObjectShowName(me.isSelected);
} else if (o.equals("bold")) {
setObjectBold(me.isSelected);
} else if (o.equals("large")) {
setObjectLarge(me.isSelected);
} else if (o.equals("longnames")) {
ZF.setLongNames(me.isSelected);
ZF.setinfo("defaults");
} else if (o.equals("obtuse")) {
setObjectObtuse(me.isSelected);
} else if (o.equals("solid")) {
setObjectSolid(me.isSelected);
} else if (o.equals("grid")) {
ZF.ZC.setAxis_show(me.isSelected);
if (me.isSelected) {
ZF.ZC.createAxisObjects();
} else {
ZF.ZC.deleteAxisObjects();
}
ZF.ZC.repaint();
ZF.setinfo("grid");
} else if (o.equals("objecttracker")) {
ZirkelFrame.ObjectConstructors[ZirkelFrame.NObjectTracker]=new ObjectTracker();
ZF.settool("objecttracker");
} else if (o.equals("locus")) {
ZirkelFrame.ObjectConstructors[ZirkelFrame.NObjectTracker]=new JLocusObjectTracker();
ZF.settool("objecttracker");
} else if (o.equals("function")) {
ZF.ZC.createCurve();
ZF.setinfo("function");
} else if (o.equals("equationxy")) {
ZF.ZC.createEquationXY();
// } else if (name.equals("manage_macros")) {
// PaletteManager.MW.ZContent.ShowLeftPanel(2);
// } else if (name.equals("help_panel")) {
// PaletteManager.MW.ZContent.ShowLeftPanel(3);
// } else if (name.equals("newmacro")) {
// PaletteManager.MW.ZContent.ShowMacroPanel();
// PaletteManager.MW.ZContent.macros.myJML.MacrosTree.JML.controls.createbtn.setSelected(true);
// PaletteManager.MW.ZContent.macros.myJML.MacrosTree.JML.createmacropanel.appeargently();
// PaletteManager.deselectgeomgroup();
// } else if (name.equals("history_panel")) {
// PaletteManager.MW.ZContent.ShowLeftPanel(1);
// // } else if (name.equals("properties_panel")){
// // JGlobals.JPB.showme(me.isSelected);
} else if (o.equals("copy")) {
FileTools.exportGraphicFile(FileTools.PNG, null);
} else if (o.equals("exportpng")) {
FileTools.exportGraphicFile(FileTools.PNG);
} else if (o.equals("exporteps")) {
FileTools.exportGraphicFile(FileTools.EPS);
} else if (o.equals("exportsvg")) {
FileTools.exportGraphicFile(FileTools.SVG);
} else if (o.equals("exportpdf")) {
FileTools.exportGraphicFile(FileTools.PDF);
} else if (o.startsWith("bi_")) {
if (o.equals("bi_function_u")) {
Global.setParameter("options.point.shownames", false);
JZF.getPointLabel().getBetterName(null, true);
}
MacroTools.runBuiltinMacro("@builtin@/"+o.substring(3));
} else if (o.equals("back")) {
ZF.ZC.back();
ZF.settool(o);
} else if (o.equals("undo")) {
ZF.ZC.undo();
ZF.settool(o);
} else if (o.equals("boundedpoint")) {
ZF.settool("boundedpoint");
} else if (o.equals("ctrl_slider")) {
ZF.ZC.setNullTool();
} else if (o.equals("ctrl_popup")) {
ZF.ZC.setNullTool();
} else if (o.equals("ctrl_chkbox")) {
ZF.ZC.setNullTool();
} else if (o.equals("ctrl_button")) {
ZF.ZC.setNullTool();
} else if (o.equals("ctrl_edit")) {
ZF.ZC.setNullTool();
} else if (o.equals("ctrl_txtfield")) {
ZF.ZC.setNullTool();
} else {
ZF.settool(o);
}
JIconMouseAdapter.setgeomSelectedIcon();
ZC.pause(false);
ZC.requestFocus();
}
private static boolean isIconWithProperties(final String name) {
final String acceptedIcons=",expression,locus,bi_function_u,text,area,area3D,ray,ray3D,segment,segment3D,"+"line,line3D,point,bi_3Dcoords,parallel,plumb,intersection,inter3D,midpoint,midpoint3D,bi_syma,bi_3Dsymp,bi_3Dproj"+"bi_symc,bi_3Dsymc,bi_trans,bi_3Dtrans,bi_3Dcircle1,bi_3Dcircle2,bi_3Dcircle3pts,bi_3Dplandroite,bi_3Dplanplan,bi_3Dsphererayon,bi_3Dspherepoint,bi_3Dspheredroite,bi_3Dsphereplan,bi_3Dspheresphere,bi_med,bi_biss,vector,vector3D,fixedsegment,circle,"+"circle3,fixedcircle,bi_arc,bi_circ,angle,angle3D,fixedangle,quadric,"+"boundedpoint,tortue";
return (acceptedIcons.indexOf(","+name+",")!=-1);
}
public static void setObjectColor(final int i) {
String iconname=PaletteManager.geomSelectedIcon();
if (isIconWithProperties(iconname)) {
iconname=PaletteManager.IconFamily(iconname);
Global.setParameter("options."+iconname+".pcolor", (Color) null);
Global.setParameter("options."+iconname+".color", i);
PaletteZone_Aspect.getColorPicker().setSelected(false);
PaletteZone_Aspect.getColorPicker().setDefaultColor();
} else {
ZF.setcolor(i);
}
}
public static void setObjectColor(final Color c) {
String iconname=PaletteManager.geomSelectedIcon();
if (isIconWithProperties(iconname)) {
iconname=PaletteManager.IconFamily(iconname);
Global.setParameter("options."+iconname+".pcolor", c);
}
}
private static void setObjectColorType(final int i) {
String iconname=PaletteManager.geomSelectedIcon();
if (isIconWithProperties(iconname)) {
iconname=PaletteManager.IconFamily(iconname);
Global.setParameter("options."+iconname+".colortype", i);
} else {
ZF.setcolortype(i);
}
}
private static void setObjectShowName(final boolean bool) {
String iconname=PaletteManager.geomSelectedIcon();
if (isIconWithProperties(iconname)) {
iconname=PaletteManager.IconFamily(iconname);
Global.setParameter("options."+iconname+".shownames", bool);
} else {
ZF.setShowNames(bool);
}
ZF.setinfo("defaults");
JZF.getPointLabel().getBetterName(null, true);
}
private static void setObjectShowValue(final boolean bool) {
String iconname=PaletteManager.geomSelectedIcon();
if (isIconWithProperties(iconname)) {
iconname=PaletteManager.IconFamily(iconname);
Global.setParameter("options."+iconname+".showvalues", bool);
} else {
ZF.ZC.setShowValues(bool);
}
}
private static void setObjectFilled(final boolean bool) {
String iconname=PaletteManager.geomSelectedIcon();
if (isIconWithProperties(iconname)) {
iconname=PaletteManager.IconFamily(iconname);
Global.setParameter("options."+iconname+".filled", bool);
} else {
// ZF.ZC.setShowValues(bool);
}
}
private static void setObjectSolid(final boolean bool) {
String iconname=PaletteManager.geomSelectedIcon();
if (isIconWithProperties(iconname)) {
iconname=PaletteManager.IconFamily(iconname);
Global.setParameter("options."+iconname+".solid", bool);
} else {
// ZF.ZC.setShowValues(bool);
}
}
private static void setObjectLarge(final boolean bool) {
String iconname=PaletteManager.geomSelectedIcon();
if (isIconWithProperties(iconname)) {
iconname=PaletteManager.IconFamily(iconname);
Global.setParameter("options."+iconname+".large", bool);
} else {
ZF.ZC.setLargeFont(bool);
}
}
private static void setObjectBold(final boolean bool) {
String iconname=PaletteManager.geomSelectedIcon();
if (isIconWithProperties(iconname)) {
iconname=PaletteManager.IconFamily(iconname);
Global.setParameter("options."+iconname+".bold", bool);
} else {
ZF.ZC.setBoldFont(bool);
}
}
private static void setObjectObtuse(final boolean bool) {
String iconname=PaletteManager.geomSelectedIcon();
if (isIconWithProperties(iconname)) {
iconname=PaletteManager.IconFamily(iconname);
Global.setParameter("options."+iconname+".obtuse", bool);
} else {
ZF.ZC.setObtuse(bool);
}
}
}

View file

@ -0,0 +1,57 @@
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package eric.GUI.palette;
import eric.GUI.themes;
import eric.JZirkelCanvas;
import java.awt.Point;
import java.awt.event.MouseEvent;
import java.awt.event.MouseMotionListener;
import rene.zirkel.ZirkelCanvas;
/**
*
* @author erichake
*/
public class JIconMouseAdapter implements MouseMotionListener {
private static ZirkelCanvas ZC=null;
private static String geomSelectedIcon="point";
private static String acceptedIcons=",hide,delete,ctrl_slider,ctrl_txtfield,ctrl_popup,ctrl_chkbox,ctrl_button,";
public static void setgeomSelectedIcon() {
ZC=JZirkelCanvas.getCurrentZC();
if (ZC!=null) {
geomSelectedIcon=PaletteManager.geomSelectedIcon();
if ((acceptedIcons.indexOf(geomSelectedIcon)==-1)||(geomSelectedIcon.equals(""))) {
ZC=null;
}
}
}
public static void deselect() {
ZC=null;
}
public static void paintTool() {
if (ZC!=null) {
final Point pt=ZC.getMousePosition();
try {
ZC.getGraphics().drawImage(ZC.I, 0, 0, ZC);
ZC.getGraphics().drawImage(themes.getPaletteImage(geomSelectedIcon), pt.x+5, pt.y+5, themes.getToolIconSize(), themes.getToolIconSize(), ZC);
} catch (Exception ex) {
}
}
}
@Override
public void mouseMoved(MouseEvent e) {
paintTool();
}
public void mouseDragged(MouseEvent e) {
}
}

View file

@ -0,0 +1,685 @@
/*
* 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<JIcon> allIcons=new ArrayList<JIcon>();
private static PaletteZone JPDisk, JPEdit, JPfunc, JPTest,
JPControls, JPHist, JPSizes, JPColors, JPPrec, JPGrid;
private static ArrayList<PaletteZone> PaletteWithIconOnly;
private static PaletteZone_Aspect JPAspect;
private static PaletteZone_Geom JPGeom;
private static PaletteZone_3D JP3D;
private static JColorPanel colorpanel;
public static ArrayList<JIcon> 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<PaletteZone>();
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<PaletteWithIconOnly.size(); i++) {
if (pz.equals(PaletteWithIconOnly.get(i))) {
return true;
}
}
return false;
}
private static void constructJPDisk() {
String icns[]={"new", "load", "save", "copy", "exportpng",
"exporteps", "exportsvg", "exportpdf"};
JPDisk=new PaletteZone(Global.Loc("palette.file"));
JPDisk.createIcons(icns, null);
MainPanel.add(JPDisk);
RestrictItems.init_disk_icns(icns);
}
private static void constructJPEdit() {
String icns[]={"move", "select", "edit"};
JPEdit=new PaletteZone(Global.Loc("palette.edit"));
JPEdit.createIcons(icns, GEOM_GROUP);
JPEdit.createIcon("back", null);
JPEdit.createIcon("delete", GEOM_GROUP);
JPEdit.createIcon("undo", null);
JPEdit.createIcon("hide", GEOM_GROUP);
JPEdit.createToggleIcon("hidden");
JPEdit.createToggleIcon("grid");
String icns1[]={"animate"};
MainPanel.add(JPEdit);
JPEdit.createIcons(icns1, GEOM_GROUP);
String icns2[]={"move", "select","edit", "back", "delete", "undo", "hide", "hidden", "grid", "animate"};
RestrictItems.init_edit_icns(icns2);
}
private static void constructJP3D() {
JP3D=new PaletteZone_3D();
MainPanel.add(JP3D);
}
private static void constructJPAspect() {
JPAspect=new PaletteZone_Aspect();
MainPanel.add(JPAspect);
}
private static void constructJPGeom() {
JPGeom=new PaletteZone_Geom();
MainPanel.add(JPGeom);
}
private static void constructJPfunc() {
final String icns[]={"tracker", "objecttracker", "locus"};
JPfunc=new PaletteZone(Global.Loc("palette.function"));
JPfunc.createIcon("bi_function_u", GEOM_GROUP);
JPfunc.createIcon("function", null);
JPfunc.createIcon("equationxy", null);
JPfunc.createIcons(icns, GEOM_GROUP);
MainPanel.add(JPfunc);
final String icns2[]={"tracker", "objecttracker", "locus", "bi_function_u", "function", "equationxy"};
RestrictItems.init_func_icns(icns2);
}
private static void constructJPTest() {
final String icns[]={"bi_t_align", "bi_t_para", "bi_t_perp",
"bi_t_equi", "bi_t_app", "bi_t_conf"};
JPTest=new PaletteZone(Global.Loc("palette.test"));
JPTest.createIcons(icns, GEOM_GROUP);
MainPanel.add(JPTest);
RestrictItems.init_test_icns(icns);
}
private static void constructJPControls() {
JPControls=new PaletteZone(Global.Loc("palette.controls"));
JPControls.createIcon("ctrl_edit", GEOM_GROUP);
ctrlJSlider=JPControls.createIcon("ctrl_slider", GEOM_GROUP);
ctrlJPopup=JPControls.createIcon("ctrl_popup", GEOM_GROUP);
ctrlJCheckBox=JPControls.createIcon("ctrl_chkbox", GEOM_GROUP);
ctrlJTextField=JPControls.createIcon("ctrl_txtfield", GEOM_GROUP);
ctrlJButton=JPControls.createIcon("ctrl_button", GEOM_GROUP);
MainPanel.add(JPControls);
final String icns[]={"ctrl_edit", "ctrl_slider", "ctrl_popup", "ctrl_chkbox", "ctrl_txtfield", "ctrl_button"};
RestrictItems.init_control_icns(icns);
}
private static void constructJPGrid() {
final String icns[]={"acolor0", "acolor1", "acolor2", "acolor3", "acolor4", "acolor5"};
JPGrid=new PaletteZone(Global.Loc("palette.grid"));
JPGrid.createIcons(icns, GRID1_GROUP);
JPGrid.createToggleIcon("dottedgrid");
JPGrid.createToggleIcon("numgrid");
JPGrid.createSimpleIcon("blank");
final String icns2[]={"athickness0", "athickness1", "athickness2"};
JPGrid.createIcons(icns2, GRID2_GROUP);
MainPanel.add(JPGrid);
}
private static void constructJPHist() {
final String icns[]={"allback", "fastback", "oneback", "oneforward",
"fastforward", "allforward", "setbreak", "nextbreak"};
JPHist=new PaletteZone(Global.Loc("palette.history"));
JPHist.createIcons(icns, null);
MainPanel.add(JPHist);
}
private static void constructJPColors() {
JPColors=new PaletteZone(Global.Loc("palette.colors"));
JPColors.addComponent(colorpanel=new JColorPanel());
JPColors.createToggleIcon("background");
JPColors.createSimpleIcon("blank");
JPColors.createSimpleIcon("blank");
final String icns[]={"imstretch", "imcenter", "imtile"};
JPColors.createIcons(icns, PHOTO_GROUP);
MainPanel.add(JPColors);
}
private static void constructJPSizes() {
JPSizes=new PaletteZone(Global.Loc("palette.sizes"));
JPSizes.addComponent(new JCursor("minpointsize", Global.Loc("palette.sizes.point"), 1, 9, 3));
JPSizes.addComponent(new JCursor("minlinesize", Global.Loc("palette.sizes.line"), 1, 9, 1));
JPSizes.addComponent(new JCursor("arrowsize", Global.Loc("palette.sizes.arrow"), 3, 50, 15));
JPSizes.addComponent(new JCursor("minfontsize", Global.Loc("palette.sizes.font"), 1, 64, 12));
JPSizes.addComponent(new JCursor("selectionsize", Global.Loc("palette.sizes.selectionsize"), 5, 20, 8));
JPSizes.addComponent(new JCursor("monkeyspeed", Global.Loc("palette.sizes.monkeyspeed"), 1, 50, 20));
JPSizes.addComponent(new JCursor("gridopacity", Global.Loc("palette.sizes.gridopacity"), 0, 100, 20));
MainPanel.add(JPSizes);
}
private static void constructJPPrec() {
JPPrec=new PaletteZone(Global.Loc("palette.prec"));
JPPrec.addComponent(new JCursor("digits.lengths", Global.Loc("palette.prec.lengths"), 0, 12, 5));
JPPrec.addComponent(new JCursor("digits.edit", Global.Loc("palette.prec.edit"), 0, 12, 5));
JPPrec.addComponent(new JCursor("digits.angles", Global.Loc("palette.prec.angles"), 0, 12, 0));
MainPanel.add(JPPrec);
}
public static void refresh() {
JPSizes.clearContent();
JPSizes.addComponent(new JCursor("minpointsize", Global.Loc("palette.sizes.point"), 1, 9, Global.getParameter("minpointsize", 3)));
JPSizes.addComponent(new JCursor("minlinesize", Global.Loc("palette.sizes.line"), 1, 9, Global.getParameter("minlinesize", 1)));
JPSizes.addComponent(new JCursor("arrowsize", Global.Loc("palette.sizes.arrow"), 3, 50, Global.getParameter("arrowsize", 15)));
JPSizes.addComponent(new JCursor("minfontsize", Global.Loc("palette.sizes.font"), 1, 64, Global.getParameter("minfontsize", 18)));
JPSizes.addComponent(new JCursor("selectionsize", Global.Loc("palette.sizes.selectionsize"), 5, 20, Global.getParameter("selectionsize", 8)));
JPSizes.addComponent(new JCursor("monkeyspeed", Global.Loc("palette.sizes.monkeyspeed"), 1, 50, Global.getParameter("monkeyspeed", 20)));
JPSizes.addComponent(new JCursor("gridopacity", Global.Loc("palette.sizes.gridopacity"), 0, 100, Global.getParameter("gridopacity", 20)));
JPSizes.revalidate();
JPSizes.repaint();
JPPrec.clearContent();
JPPrec.addComponent(new JCursor("digits.lengths", Global.Loc("palette.prec.lengths"), 0, 12, Global.getParameter("digits.lengths", 2)));
JPPrec.addComponent(new JCursor("digits.edit", Global.Loc("palette.prec.edit"), 0, 12, Global.getParameter("digits.edit", 4)));
JPPrec.addComponent(new JCursor("digits.angles", Global.Loc("palette.prec.angles"), 0, 12, Global.getParameter("digits.angles", 2)));
JPPrec.revalidate();
JPPrec.repaint();
JPAspect.initPointNameBtn();
colorpanel.refresh();
setSelected_with_clic("grid", Global.getParameter("axis_show", false));
setSelected_with_clic("acolor"+Global.getParameter("axis_color", 0), true);
setSelected_with_clic("athickness"+Global.getParameter("axis_thickness", 0), true);
setSelected_with_clic("numgrid", Global.getParameter("axis_labels", true));
setSelected_with_clic("dottedgrid", Global.getParameter("axis_with_grid", true));
}
public static void fixRestrictedEnvironment() {
ZirkelCanvas zc=JZirkelCanvas.getCurrentZC();
if ((zc!=null)) {
JPDisk.setVisible(!zc.isHiddenItem(RestrictItems.DISK));
JPEdit.setVisible(!zc.isHiddenItem(RestrictItems.EDIT));
JPGeom.setVisible(!zc.isHiddenItem(RestrictItems.GEOM));
JPAspect.setVisible(!zc.isHiddenItem(RestrictItems.ASPECT));
JPfunc.setVisible(!zc.isHiddenItem(RestrictItems.FUNC));
JPTest.setVisible(!zc.isHiddenItem(RestrictItems.TEST));
JPControls.setVisible(!zc.isHiddenItem(RestrictItems.CTRL));
JPGrid.setVisible(!zc.isHiddenItem(RestrictItems.GRID));
JPHist.setVisible(!zc.isHiddenItem(RestrictItems.HIST));
JPColors.setVisible(!zc.isHiddenItem(RestrictItems.BACK));
JPSizes.setVisible(!zc.isHiddenItem(RestrictItems.SIZE));
JPPrec.setVisible(!zc.isHiddenItem(RestrictItems.PREC));
MenuBar.setMenuVisible(!zc.isHiddenItem(RestrictItems.MENU));
zc.setLibraryMacrosVisible(!zc.isHiddenItem(RestrictItems.LMCR));
LeftPanel.setMacroBtnVisible(!zc.isHiddenItem(RestrictItems.MCRP));
LeftPanel.setHistoryBtnVisible(!zc.isHiddenItem(RestrictItems.HISTP));
LeftPanel.setHelpBtnVisible(!zc.isHiddenItem(RestrictItems.HLPP));
for (int i=0; i<allIcons.size(); i++) {
JIcon ji=allIcons.get(i);
ji.setVisible(!zc.isHiddenItem(ji.getIconName()));
}
zc.reloadCD();
}
}
public static String ToolTip(final String s) {
String ToolTipText="";
final String purename=(s.startsWith("bi_"))?s.substring(3):s;
ToolTipText=Global.Loc("palette.info."+purename);
if (ToolTipText==null) {
ToolTipText=Global.Loc("palette.info."+s);
}
if (ToolTipText==null) {
ToolTipText=Global.Loc("iconhelp."+purename);
}
if (ToolTipText==null) {
ToolTipText=Global.Loc("palette.info.DP_"+s);
}
return ToolTipText;
}
public static void FixPaletteHeight(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.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<allIcons.size(); i++) {
if (!allIcons.get(i).equals(icn)) {
allIcons.get(i).setOver(false);
}
}
MainPanel.repaint();
}
public static void setSelectBtn(JIcon icn) {
if (!icn.isPushButton()) {
if (icn.isToggleButton()) {
icn.setSelected(!icn.isSelected());
icn.repaint();
} else {
icn.setSelected(true);
for (int i=0; i<allIcons.size(); i++) {
if (icn.getIconGroup().equals(allIcons.get(i).getIconGroup())&&(!allIcons.get(i).equals(icn))) {
allIcons.get(i).setSelected(false);
}
}
MainPanel.repaint();
}
}
}
public static void repaint() {
MainPanel.repaint();
}
public static String IconFamily(final String name) {
String f=",ray,parallel,plumb,bi_med,bi_biss,ray3D,line3D,bi_3Dplanplan,";
if (f.indexOf(","+name+",")!=-1) {
return "line";
}
f=",intersection,midpoint,bi_syma,bi_symc,bi_trans,boundedpoint,midpoint3D,bi_3Dcoords,bi_3Dsymp,bi_3Dproj,bi_3Dsymc,bi_3Dtrans,bi_3Dplandroite,bi_3Dspheredroite,inter3D,";
if (f.indexOf(","+name+",")!=-1) {
return "point";
}
f=",vector,fixedsegment,vector3D,segment3D,";
if (f.indexOf(","+name+",")!=-1) {
return "segment";
}
f=",circle3,fixedcircle,bi_arc,bi_circ,bi_3Dsphererayon,bi_3Dspherepoint,";
if (f.indexOf(","+name+",")!=-1) {
return "circle";
}
f=",bi_3Dcircle1,bi_3Dcircle2,bi_3Dcircle3pts,bi_3Dsphereplan,bi_3Dspheresphere,";
if (f.indexOf(","+name+",")!=-1) {
return "quadric";
}
f=",bi_function_u,expression,text,";
if (f.indexOf(","+name+",")!=-1) {
return "text";
}
f=",fixedangle,angle3D,";
if (f.indexOf(","+name+",")!=-1) {
return "angle";
}
f=",area3D,";
if (f.indexOf(","+name+",")!=-1) {
return "area";
}
f=",image3,";
if (f.indexOf(","+name+",")!=-1) {
return "image";
}
return name;
}
public static void deselectgeomgroup() {
for (int i=0; i<allIcons.size(); i++) {
if (GEOM_GROUP.equals(allIcons.get(i).getIconGroup())) {
allIcons.get(i).setSelected(false);
allIcons.get(i).repaint();
}
}
JIconMouseAdapter.deselect();
}
public static String getGeomGroup(){
return GEOM_GROUP;
}
public static void remove3DPalette(){
MainPanel.remove(JP3D);
}
public static void add3DPalette(){
MainPanel.add(JP3D,2);
}
public static boolean isGeomGroup(String name) {
name=name.replace("3D",""); //Dibs
for (int i=0; i<allIcons.size(); i++) {
JIcon ji=allIcons.get(i);
if (allIcons.get(i).getIconName().replace("3D","").equals(name)) {// Dibs
return GEOM_GROUP.equals(ji.getIconGroup());
}
}
return false;
}
public static void setGoodProperties(final String iconname) {
int i=0;
boolean b=false;
if (isGeomGroup(iconname)) {
final String familyIcon=IconFamily(iconname);
i=Global.getParameter("options."+familyIcon+".color", 0);
final Color col=Global.getParameter("options."+familyIcon+".pcolor", (Color) null);
if (col==null) {
setSelected_with_clic("color"+i, true);
PaletteZone_Aspect.getColorPicker().setDefaultColor();
} else {
PaletteZone_Aspect.getColorPicker().Select();
PaletteZone_Aspect.getColorPicker().setCurrentColor(col);
}
i=Global.getParameter("options."+familyIcon+".colortype", 0);
setSelected_with_clic("thickness"+i, true);
b=Global.getParameter("options."+familyIcon+".shownames",
false);
setSelected_with_clic("showname", b);
b=Global.getParameter("options."+familyIcon+".showvalues",
false);
setSelected_with_clic("showvalue", b);
b=Global.getParameter("options."+familyIcon+".filled", false);
setSelected_with_clic("filled", b);
b=Global.getParameter("options."+familyIcon+".solid", false);
setSelected_with_clic("solid", b);
b=Global.getParameter("options."+familyIcon+".bold", false);
setSelected_with_clic("bold", b);
b=Global.getParameter("options."+familyIcon+".large", false);
setSelected_with_clic("large", b);
b=Global.getParameter("options."+familyIcon+".obtuse", false);
setSelected_with_clic("obtuse", b);
if (Global.getParameter("background.usesize", false)) {
setSelected_with_clic("imstretch", true);
} else if (Global.getParameter("background.tile", false)) {
setSelected_with_clic("imtile", true);
} else if (Global.getParameter("background.center", false)) {
setSelected_with_clic("imcenter", true);
}
JPAspect.setLabel(Global.Loc("palette.aspect.label.text_title")+" "+Global.Loc("palette.aspect.label."+familyIcon)+" :");
setAspectDisabledState(iconname);
}
}
public static void setAspectDisabledState(final String iconname) {
final String AspectIcons=" bold large filled"
+" thickness0 thickness1 thickness2"
+" color0 color1 color2 color3 color4 color5"
+" obtuse plines partial solid showvalue showname ";
setDisabledIcons(AspectIcons, false);
final String familyIcon=IconFamily(iconname);
if (familyIcon.equals("point")) {
setDisabledIcons(" filled obtuse plines partial solid ", true);
} else if (familyIcon.equals("line")) {
setDisabledIcons(" filled obtuse partial solid showvalue ", true);
} else if (familyIcon.equals("segment")) {
setDisabledIcons(" filled obtuse partial plines solid ", true);
} else if (familyIcon.equals("angle")) {
setDisabledIcons(" partial plines ", true);
} else if (familyIcon.equals("circle")) {
setDisabledIcons(" obtuse plines ", true);
} else if (familyIcon.equals("area")) {
setDisabledIcons(" bold large obtuse plines partial showname ",
true);
} else if (familyIcon.equals("text")) {
setDisabledIcons(" showvalue filled obtuse plines partial solid ",
true);
} else if (familyIcon.equals("locus")) {
setDisabledIcons(
" bold large obtuse plines partial solid showvalue showname ",
true);
} else if (familyIcon.equals("tracker")) {
setDisabledIcons(
" bold large filled thickness0 thickness1 thickness2 color0 color1 color2 color3 color4 color5 obtuse plines partial solid showvalue showname ",
true);
} else if (familyIcon.equals("quadric")) {
setDisabledIcons(" obtuse plines partial solid filled showvalue ", true);
} else {
setDisabledIcons(AspectIcons, true);
}
//if (iconname.equals("quadric")) {
// setDisabledIcons(" partial filled ", true);
// }
if (iconname.equals("text")) {
setDisabledIcons(" showname ", true);
}
}
// Disable/Enable Icons list : string with space separator
public static void setDisabledIcons(String iconname, boolean dis) {
JIcon myicon;
for (int i=0; i<allIcons.size(); i++) {
myicon=(JIcon) allIcons.get(i);
if (iconname.indexOf(" "+myicon.getIconName()+" ")!=-1) {
if (myicon.isDisabled()!=dis) {
myicon.setDisabled(dis);
}
myicon.repaint();
if (myicon.getIconName().equals("color0")) {
PaletteZone_Aspect.getColorPicker().setDisabled(dis);
PaletteZone_Aspect.getColorPicker().repaint();
}
}
}
}
public static void ClicOn(final String iconname) {
JIcon myicon;
for (int i=0; i<allIcons.size(); i++) {
myicon=(JIcon) allIcons.get(i);
if (iconname.equals(myicon.getIconName())) {
myicon.ClicOnMe();
return;
}
}
}
public static void setSelected(String iconname, boolean sel) {
JIcon myicon;
for (int i=0; i<allIcons.size(); i++) {
myicon=(JIcon) allIcons.get(i);
if (myicon.getIconName().equals(iconname)) {
myicon.setSelected(sel);
return;
}
}
}
public static void setSelected_with_clic(String iconname, boolean sel) {
JIcon myicon;
for (int i=0; i<allIcons.size(); i++) {
myicon=(JIcon) allIcons.get(i);
if (myicon.getIconName().equals(iconname)) {
if (myicon.isSelected()!=sel) {
myicon.ClicOnMe();
}
return;
}
}
}
public static boolean setSelected_with_clic2(String iconname, boolean sel) { // Dibs : for CaRScripts
JIcon myicon;
boolean changed=false;
for (int i=0; i<allIcons.size(); i++) {
myicon=(JIcon) allIcons.get(i);
if (myicon.getIconName().equals(iconname)) {
if (myicon.isSelected()!=sel) {
myicon.ClicOnMe();
changed=true;
}
return changed;
}
}
return false;
}
public static String geomSelectedIcon() {
for (int i=0; i<allIcons.size(); i++) {
if (GEOM_GROUP.equals(allIcons.get(i).getIconGroup())) {
if (allIcons.get(i).isSelected()) {
return allIcons.get(i).getIconName();
}
}
}
return "";
}
public static void selectGeomIcon() {
for (int i=0; i<allIcons.size(); i++) {
if (GEOM_GROUP.equals(allIcons.get(i).getIconGroup())) {
if (allIcons.get(i).isSelected()) {
allIcons.get(i).ClicOnMe();
return;
}
}
}
}
public static boolean isSelected(final String iconname) {
for (int i=0; i<allIcons.size(); i++) {
if (iconname.equals(allIcons.get(i).getIconName())) {
return allIcons.get(i).isSelected();
}
}
return false;
}
public static void initPaletteConsideringMode() {
JPGeom.initConsideringMode();
JP3D.initConsideringMode();
FixPaletteHeight(null);
}
}

View file

@ -0,0 +1,179 @@
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package eric.GUI.palette;
import eric.GUI.windowComponent;
import java.awt.Graphics;
import java.awt.event.MouseEvent;
import java.util.ArrayList;
import javax.swing.BoxLayout;
import javax.swing.JComponent;
import rene.gui.Global;
/**
*
* @author erichake
*/
public class PaletteZone extends windowComponent {
protected ArrayList<JIcon> icons=new ArrayList<JIcon>();
protected PaletteZoneTitle zone_title;
protected PaletteZoneContent zone_content;
private String zone_name;
private PaletteZone me;
// @Override
// public void paintComponent(Graphics g) {
// }
public PaletteZone(String name) {
super();
me=this;
zone_name=name;
setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
setAlignmentX(0.0f);
zone_title=new PaletteZoneTitle(name) {
@Override
public void mouseClicked(MouseEvent e) {
ToggleHideOrShow();
PaletteManager.FixPaletteHeight(me);
}
};
add(zone_title);
zone_content=new PaletteZoneContent(this);
add(zone_content);
// HideOrShow();
}
private void HideOrShow() {
hide_zone(Global.getParameter("hidepalette."+zone_name, false));
}
private void ToggleHideOrShow() {
hide_zone(!Global.getParameter("hidepalette."+zone_name, false));
}
private void hide_zone(boolean b) {
Global.setParameter("hidepalette."+zone_name, b);
zone_title.setHide(b);
zone_content.setHide(b);
}
public void init() {
validate();
HideOrShow();
zone_title.init();
for (JIcon element : icons) {
element.init();
}
zone_content.init();
}
public void setHideContent(boolean b) {
hide_zone(b);
}
public void setVisibleContentHeight() {
zone_content.setVisibleHeight();
}
public void clearContent() {
zone_content.removeAll();
}
public JIcon createToggleIcon(String name) {
JIcon ji=new JIcon(name, name);
addIcon(ji);
return ji;
}
public JIcon createSimpleIcon(String name) {
JIcon ji=new JIcon(name, null);
addIcon(ji);
return ji;
}
public JIcon createIcon(String name, String group) {
JIcon ji=new JIcon(name, group);
addIcon(ji);
return ji;
}
public void createIcons(String myname[], String group) {
for (String element : myname) {
createIcon(element, group);
}
}
// Seulement pour la zone Construction, et seulement dans
// le cas il s'agit d'un modeDP :
public void insertEuclidianCheckBox(){
}
// names est une chaine du type " nom1 nom2 nom3 "
public void insertIcons(String names, String group) {
String myname[]=names.trim().split(" ");
for (String element : myname) {
if ((element.equals("blank"))||(findIcon(element)==null)) {
// if (findIcon(element)==null) {
JIcon ji=createIcon(element, group);
PaletteManager.fixsize(ji, ji.getIconWidth(), ji.getIconWidth());
}
}
}
public JIcon findIcon(String name) {
for (JIcon ji : icons) {
if (name.equals(ji.getIconName())) {
return ji;
}
}
return null;
}
public void removeBlankIcons() {
ArrayList<JIcon> blanks=new ArrayList<JIcon>();
for (JIcon ji : icons) {
if (ji.getIconName().equals("blank")) {
blanks.add(ji);
}
}
for (JIcon ji : blanks) {
removeIcon(ji);
PaletteManager.removeIcon(ji);
}
}
// names est une chaine du type " nom1 nom2 nom3 "
public void removeIcons(String names) {
ArrayList<JIcon> icns=new ArrayList<JIcon>();
String myname[]=names.trim().split(" ");
for (String element : myname) {
JIcon ji=findIcon(element);
if (ji!=null) {
icns.add(ji);
}
}
for (JIcon ji : icns) {
removeIcon(ji);
PaletteManager.removeIcon(ji);
}
}
public void removeIcon(JIcon ji) {
icons.remove(ji);
zone_content.remove(ji);
}
public void addIcon(JIcon ji) {
icons.add(ji);
zone_content.add(ji);
}
public void addComponent(JComponent jc) {
zone_content.add(jc);
}
}

View file

@ -0,0 +1,63 @@
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package eric.GUI.palette;
import eric.JZirkelCanvas;
import java.awt.AlphaComposite;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
import javax.swing.JCheckBox;
import javax.swing.JLabel;
import javax.swing.SwingConstants;
import rene.gui.Global;
import rene.zirkel.ZirkelCanvas;
/**
*
* @author erichake
*/
public class PaletteZoneCheckBox extends JCheckBox implements ItemListener{
public PaletteZoneCheckBox(String txt) {
super(txt);
setOpaque(false);
setFocusable(false);
setFont(new java.awt.Font(Global.GlobalFont, 1, 11));
setForeground(new Color(100, 100, 100));
setHorizontalAlignment(SwingConstants.CENTER);
putClientProperty("JComponent.sizeVariant", "mini");
addItemListener(this);
}
public void paintComponent(Graphics g) {
Dimension d=getSize();
Graphics2D g2=(Graphics2D) g;
g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.05f));
g2.setColor(new Color(0, 0, 255));
g2.fillRect(3, 3, d.width-6, d.height-6);
g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.15f));
g2.drawRect(3, 3, d.width-7, d.height-7);
g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 1f));
super.paintComponent(g);
}
public void itemStateChanged(ItemEvent e) {
ZirkelCanvas zc=JZirkelCanvas.getCurrentZC();
if (zc!=null){
zc.setEuclidian(isSelected());
zc.repaint();
}
PaletteManager.initPaletteConsideringMode();
PaletteManager.init();
PaletteManager.selectGeomIcon();
}
}

View file

@ -0,0 +1,76 @@
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package eric.GUI.palette;
import eric.GUI.themes;
import eric.GUI.windowComponent;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.Graphics;
import java.awt.Image;
import javax.swing.JComponent;
/**
*
* @author erichake
*/
public class PaletteZoneContent extends windowComponent {
private static Image back=themes.getImage("palbackground.gif");
private boolean visible=true;
private int height=-1;
private PaletteZone parent;
@Override
public void paintComponent(Graphics g) {
Dimension d=getSize();
g.drawImage(back, 0, 0, d.width, d.height, this);
}
// For Restricted Palette only :
public void setVisibleHeight() {
int nb=0;
// count visible icons :
for (int i=0; i<getComponentCount(); i++) {
JComponent ji=(JComponent) getComponent(i);
if (ji.isVisible()) {
nb++;
}
}
int w=themes.getPaletteIconWidth()*themes.getPaletteIconPerRow();
int h=themes.getPaletteIconWidth()*(1+(nb-1)/themes.getPaletteIconPerRow());
PaletteManager.fixsize(this, w, h);
}
public void init() {
if ((visible)&&(getComponentCount()>0)) {
if (PaletteManager.isPaletteWithIconOnly(parent)) {
setVisibleHeight();
} else {
JComponent ji=(JComponent) getComponent(getComponentCount()-1);
int start=getSize().height;
int bottom=ji.getBounds().y+ji.getBounds().height;
PaletteManager.fixsize(this, themes.getRightPanelWidth(), bottom);
}
} else {
PaletteManager.fixsize(this, themes.getRightPanelWidth(), 0);
}
}
public void setHide(boolean b) {
visible=!b;
}
public boolean isHidden(){
return !visible;
}
public PaletteZoneContent(PaletteZone zone) {
super();
parent=zone;
setLayout(new FlowLayout(FlowLayout.LEFT, 0, 0));
setAlignmentX(0.0f);
}
}

View file

@ -0,0 +1,41 @@
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package eric.GUI.palette;
import java.awt.AlphaComposite;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Graphics2D;
import javax.swing.JLabel;
import javax.swing.SwingConstants;
import rene.gui.Global;
/**
*
* @author erichake
*/
public class PaletteZoneLabel extends JLabel {
public PaletteZoneLabel(String txt) {
super(txt);
setOpaque(false);
setFont(new java.awt.Font(Global.GlobalFont, 1, 11));
setForeground(new Color(100, 100, 100));
setHorizontalAlignment(SwingConstants.CENTER);
}
public void paintComponent(Graphics g) {
Dimension d=getSize();
Graphics2D g2=(Graphics2D) g;
g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.05f));
g2.setColor(new Color(0, 0, 255));
g2.fillRect(3, 3, d.width-6, d.height-6);
g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.15f));
g2.drawRect(3, 3, d.width-7, d.height-7);
g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 1f));
super.paintComponent(g);
}
}

View file

@ -0,0 +1,83 @@
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package eric.GUI.palette;
import eric.GUI.themes;
import eric.GUI.windowComponent;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Image;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import javax.swing.BoxLayout;
import javax.swing.Icon;
import javax.swing.ImageIcon;
import javax.swing.JLabel;
import javax.swing.SwingConstants;
import rene.gui.Global;
/**
*
* @author erichake
*/
public class PaletteZoneTitle extends windowComponent {
private static Image offimage=themes.getImage("PaletteTitleBarN.png");
private static Image onimage=themes.getImage("PaletteTitleBarH.png");
private static Image rightTriangle=themes.getPaletteImage("PaletteTriangleDroite");
private static Image bottomTriangle=themes.getPaletteImage("PaletteTriangleBas");
private static boolean active=false;
private JLabel title=new JLabel();
@Override
public void paintComponent(Graphics g) {
Dimension d=getSize();
if (active) {
g.drawImage(onimage, 0, 0, d.width, d.height, this);
} else {
g.drawImage(offimage, 0, 0, d.width, d.height, this);
}
}
public void init() {
PaletteManager.fixsize(this, themes.getRightPanelWidth(), themes.getPaletteZoneTitleHeight());
}
public PaletteZoneTitle(String name) {
super();
setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
setAlignmentX(0.0f);
title.setText(name);
title.setIcon(new ImageIcon(bottomTriangle));
setHide(Global.getParameter("hidepalette." + name, true));
title.setIconTextGap(7);
title.setFont(new java.awt.Font(Global.GlobalFont, 0, 11));
title.setHorizontalAlignment(SwingConstants.LEFT);
PaletteManager.fixsize(title, themes.getRightPanelWidth()-themes.getPaletteZoneTitleHeight(), themes.getPaletteZoneTitleHeight());
add(title);
}
public void setHide(boolean b){
if (b) title.setIcon(new ImageIcon(rightTriangle));
else title.setIcon(new ImageIcon(bottomTriangle));
repaint();
}
@Override
public void mousePressed(MouseEvent e) {
active=true;
repaint();
}
@Override
public void mouseReleased(MouseEvent e) {
active=false;
repaint();
}
}

View file

@ -0,0 +1,40 @@
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package eric.GUI.palette;
import static eric.GUI.palette.PaletteManager.setSelected_with_clic;
import eric.JZirkelCanvas;
import rene.gui.Global;
import rene.zirkel.ZirkelCanvas;
import rene.zirkel.construction.Construction;
/**
*
* @author erichake
*/
public class PaletteZone_3D extends PaletteZone {
private String icns[]={"bi_3Dcoords", "inter3D", "boundedpoint", "bi_3Darete", "midpoint3D", "bi_3Dproj", "bi_3Dsymc", "bi_3Dsymp", "bi_3Dtrans", "vector3D", "line3D", "ray3D", "segment3D", "area3D", "bi_3Dsphererayon", "bi_3Dspherepoint", "bi_3Dcircle1", "bi_3Dcircle2", "bi_3Dcircle3pts", "angle3D", "bi_3Dplandroite", "bi_3Dplanplan", "bi_3Dspheredroite", "bi_3Dsphereplan", "bi_3Dspheresphere", "bi_3Dtetra", "bi_3Dcube", "bi_3Docta", "bi_3Disoc", "bi_3Ddode"};
public PaletteZone_3D() {
super(Global.Loc("palette.3D"));
createIcons(icns, PaletteManager.getGeomGroup());
//setSelectBtn("bi_3Dcoords",true);
}
public void initConsideringMode() {
ZirkelCanvas zc=JZirkelCanvas.getCurrentZC();
if (zc==null) {
return;
}
PaletteManager.remove3DPalette();
if (zc.getMode()==Construction.MODE_3D) {
PaletteManager.add3DPalette();
PaletteManager.FixPaletteHeight2(this); // Dibs
setHideContent(false);
init();
}
}
}

View file

@ -0,0 +1,159 @@
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package eric.GUI.palette;
import eric.GUI.themes;
import eric.JColorPicker;
import eric.JZirkelCanvas;
import java.awt.Color;
import java.util.Vector;
import javax.swing.BoxLayout;
import javax.swing.JButton;
import eric.JEricPanel;
import javax.swing.SwingConstants;
import rene.gui.Global;
import rene.zirkel.ZirkelCanvas;
/**
*
* @author erichake
*/
public class PaletteZone_Aspect extends PaletteZone {
private static int content_height;
private static String[] types={"type0", "type1", "type2", "type3", "type4", "type5"};
private static String[] colors= { "color0", "color1", "color2", "color3","color4", "color5" };
private static String[] thickness = { "thickness0", "thickness1", "thickness2" };
private static int label_lineheight=20;
private static PaletteZoneLabel pointshape_label,aspect_label;
private static JEricPanel point_name_panel;
private static JColorPicker color_picker;
public PaletteZone_Aspect() {
super(Global.Loc("palette.aspect"));
pointshape_label=addLabel(Global.Loc("palette.aspect.label.pointshape"));
point_name_panel=new JEricPanel();
point_name_panel.setLayout(new BoxLayout(point_name_panel, BoxLayout.X_AXIS));
point_name_panel.setOpaque(false);
add7iconsString(types,PaletteManager.POINT_GROUP);
addComponent(point_name_panel);
aspect_label=addLabel("");
Vector<JIcon> V=add7iconsString(colors, PaletteManager.ASPECT1_GROUP);
color_picker=new JColorPicker(V.get(0).getIconWidth(), 6, 3,V){
@Override
public void doChange() {
JIcon.setObjectColor(getCurrentColor());
}
@Override
public void afterSelect() {
JIcon.setObjectColor(getCurrentColor());
// JPM.MW.ZF.setinfo("prop_scolor", false);
}
@Override
public void setPalettes() {
ZirkelCanvas zc=JZirkelCanvas.getCurrentZC();
if (zc!=null){
setUsedColors(zc.getConstruction().getSpecialColors());
}
}
};
addComponent(color_picker);
createIcons(thickness,PaletteManager.ASPECT2_GROUP);
createToggleIcon("partial");
createToggleIcon("plines");
createToggleIcon("showvalue");
createToggleIcon("showname");
createToggleIcon("bold");
createToggleIcon("large");
createToggleIcon("filled");
createToggleIcon("obtuse");
createToggleIcon("solid");
// setContentHeight(200);
}
public static JColorPicker getColorPicker(){
return color_picker;
}
public void init() {
PaletteManager.fixsize(pointshape_label, themes.getRightPanelWidth(), label_lineheight);
PaletteManager.fixsize(aspect_label, themes.getRightPanelWidth(), label_lineheight);
initPointNameBtn();
super.init();
}
public void initPointNameBtn() {
point_name_panel.removeAll();
JZirkelCanvas JZF=JZirkelCanvas.getCurrentJZF();
if (JZF!=null) {
point_name_panel.add(JZF.getPointLabel().getPaletteButton());
JButton jb=JZF.getPointLabel().getPaletteButton();
int w=(themes.getPaletteIconPerRow()*themes.getPaletteIconWidth())/7;
PaletteManager.fixsize(jb, w, w);
point_name_panel.add(jb);
point_name_panel.validate();
point_name_panel.repaint();
}
}
public void setLabel(String s){
aspect_label.setText(s);
repaint();
}
private PaletteZoneLabel addLabel(final String mytxt) {
PaletteZoneLabel mylabel=new PaletteZoneLabel(mytxt);
addComponent(mylabel);
return mylabel;
}
private Vector add7iconsString(String icns[],String group) {
Vector V=new Vector();
for (final String element : icns) {
JIcon ji=new JIcon(element,group , 7);
addIcon(ji);
V.add(ji);
}
return V;
}
public void addColorIcons(final String myname[], String group) {
add7iconsString(myname, group);
addComponent(JColorPicker.margin(5));
// JColorPicker jcp=new JColorPicker(themes.getPaletteIconWidth()-5, 6, 3) {
//
// /**
// *
// */
//
//
// @Override
// public void doChange() {
// JPM.setObjectColor(getCurrentColor());
// }
//
// @Override
// public void afterSelect() {
// JPM.setObjectColor(getCurrentColor());
// JPM.MW.ZF.setinfo("prop_scolor", false);
// }
//
// @Override
// public void setPalettes() {
// setUsedColors(JPM.MW.ZF.ZC.getConstruction().getSpecialColors());
// }
// };
// myLine.add(JPM.MW.ColorPicker);
// addNewLine();
}
}

View file

@ -0,0 +1,72 @@
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package eric.GUI.palette;
import eric.GUI.themes;
import eric.JZirkelCanvas;
import eric.restrict.RestrictItems;
import rene.gui.Global;
import rene.zirkel.ZirkelCanvas;
import rene.zirkel.construction.Construction;
/**
*
* @author erichake
*/
public class PaletteZone_Geom extends PaletteZone {
private String icns[]={"point", "intersection", "midpoint", "bi_syma",
"bi_symc", "bi_trans", "line", "ray", "parallel", "plumb",
"bi_med", "bi_biss", "segment", "fixedsegment", "vector",
"area", "angle", "fixedangle", "circle", "fixedcircle",
"circle3", "bi_circ", "bi_arc", "quadric", "text", "expression", "image3"};
private String DPDisabledIcons=" parallel fixedsegment fixedcircle vector area bi_arc quadric bi_trans ";
private String DPNewIcons=" bi_distance bi_perp_common bi_lineIP bi_horocycle bi_equidistante blank bi_pinceau1 bi_pinceau3 bi_pinceauinter bi_pinceauhauteur bi_pinceaucycle bi_pinceaubiss ";
private PaletteZoneCheckBox euclidianBox=new PaletteZoneCheckBox(Global.Loc("palette.construction.euclidian"));
private static int box_lineheight=25;
public PaletteZone_Geom() {
super(Global.Loc("palette.construction"));
createIcons(icns, PaletteManager.getGeomGroup());
RestrictItems.init_geom_icns(icns);
}
@Override
public void init() {
PaletteManager.fixsize(euclidianBox, themes.getRightPanelWidth(), 0);
super.init();
ZirkelCanvas zc=JZirkelCanvas.getCurrentZC();
if ((!zone_content.isHidden())&&(zc!=null)&&(zc.isDP())) {
PaletteManager.fixsize(euclidianBox, themes.getRightPanelWidth(), box_lineheight);
int w=zone_content.getWidth();
int h=zone_content.getHeight()+box_lineheight;
PaletteManager.fixsize(zone_content, w, h);
}
}
public void initConsideringMode() {
ZirkelCanvas zc=JZirkelCanvas.getCurrentZC();
if (zc==null) {
return;
}
removeBlankIcons();
PaletteManager.setDisabledIcons(DPDisabledIcons, false);
removeIcons(DPNewIcons);
zone_content.remove(euclidianBox);
if (zc.isDP()) {
zone_content.add(euclidianBox, 0);
if (!zc.isEuclidian()) {
PaletteManager.setDisabledIcons(DPDisabledIcons, true);
removeIcons(" text expression image3 ");
insertIcons(DPNewIcons, PaletteManager.getGeomGroup());
insertIcons(" text expression image3 ", PaletteManager.getGeomGroup());
PaletteManager.setDisabledIcons(" filled ", true);
}
}
}
}