Make first real commit: copy of CaRMetal 4.2.8
This commit is contained in:
parent
002acfc88e
commit
c312811084
1120 changed files with 226843 additions and 1 deletions
70
eric/restrict/RestrictContainer.java
Normal file
70
eric/restrict/RestrictContainer.java
Normal file
|
|
@ -0,0 +1,70 @@
|
|||
/*
|
||||
* To change this template, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package eric.restrict;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.util.Vector;
|
||||
import javax.swing.BorderFactory;
|
||||
import javax.swing.BoxLayout;
|
||||
import eric.JEricPanel;
|
||||
import javax.swing.JScrollPane;
|
||||
import rene.util.xml.XmlTree;
|
||||
import rene.zirkel.ZirkelCanvas;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author erichake
|
||||
*/
|
||||
public class RestrictContainer extends JEricPanel {
|
||||
|
||||
private ZirkelCanvas ZC;
|
||||
private static int W=500,H=400;
|
||||
private JScrollPane scroll;
|
||||
private RestrictPanel panel;
|
||||
private RestrictContainerTitle title;
|
||||
|
||||
public RestrictContainer(ZirkelCanvas zc) {
|
||||
ZC=zc;
|
||||
setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
|
||||
setBorder(BorderFactory.createEtchedBorder());
|
||||
setBackground(new Color(255,255,255,100));
|
||||
title=new RestrictContainerTitle();
|
||||
panel=new RestrictPanel();
|
||||
scroll=new JScrollPane(panel);
|
||||
scroll.setBorder(BorderFactory.createEmptyBorder());
|
||||
scroll.getVerticalScrollBar().setUnitIncrement(24);
|
||||
scroll.setOpaque(false);
|
||||
add(title);
|
||||
add(scroll);
|
||||
add(new RestrictContainerControls(panel,ZC));
|
||||
}
|
||||
|
||||
public void init() {
|
||||
int x=(ZC.getSize().width-W)/2;
|
||||
int y=(ZC.getSize().height-H)/2;
|
||||
setBounds(x, y, W, H);
|
||||
}
|
||||
|
||||
public void selectFromZC(){
|
||||
|
||||
}
|
||||
|
||||
public static int getContainerWidth(){
|
||||
return W;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public void removeRestrictItem(RestrictPanelIcon si) {
|
||||
}
|
||||
|
||||
public void removeRestrictItem(String nme) {
|
||||
}
|
||||
|
||||
public void addRestrictItem(XmlTree tree) {
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
115
eric/restrict/RestrictContainerControls.java
Normal file
115
eric/restrict/RestrictContainerControls.java
Normal file
|
|
@ -0,0 +1,115 @@
|
|||
/*
|
||||
* To change this template, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package eric.restrict;
|
||||
|
||||
import eric.GUI.palette.PaletteManager;
|
||||
import eric.GUI.themes;
|
||||
import java.awt.Color;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.Font;
|
||||
import java.awt.Graphics;
|
||||
import java.awt.Image;
|
||||
import java.awt.event.MouseAdapter;
|
||||
import java.awt.event.MouseEvent;
|
||||
import java.util.ArrayList;
|
||||
import javax.swing.BoxLayout;
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JLabel;
|
||||
import eric.JEricPanel;
|
||||
import javax.swing.SwingConstants;
|
||||
import rene.gui.Global;
|
||||
import rene.zirkel.ZirkelCanvas;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author erichake
|
||||
*/
|
||||
public class RestrictContainerControls extends JEricPanel {
|
||||
|
||||
ZirkelCanvas ZC;
|
||||
private static Image offimage=themes.getImage("tab_bottom.gif");
|
||||
private ArrayList<String> originalItems;
|
||||
private RestrictPanel panel;
|
||||
|
||||
@Override
|
||||
public void paintComponent(Graphics g){
|
||||
Dimension d=getSize();
|
||||
g.setColor(new Color(230,230,230));
|
||||
g.fillRect(0, 0, d.width, d.height);
|
||||
g.setColor(new Color(130,130,130));
|
||||
g.drawLine(0, 0, d.width, 0);
|
||||
}
|
||||
|
||||
public RestrictContainerControls(RestrictPanel pan,ZirkelCanvas zc) {
|
||||
ZC=zc;
|
||||
panel=pan;
|
||||
// backup of restricted hidden items :
|
||||
originalItems=new ArrayList<String>();
|
||||
ArrayList<String> items=ZC.getHiddenItems();
|
||||
for (int i=0;i<items.size();i++){
|
||||
originalItems.add(items.get(i));
|
||||
};
|
||||
|
||||
setOpaque(false);
|
||||
setLayout(new BoxLayout(this, BoxLayout.X_AXIS));
|
||||
myJButton closebtn=new myJButton(80, Global.Loc("restrict.ok")){
|
||||
@Override
|
||||
public void action(){
|
||||
ZC.setStandardRestrictedItems();
|
||||
ZC.closeRestrictDialog();
|
||||
}
|
||||
};
|
||||
myJButton cancelbtn=new myJButton(80, Global.Loc("restrict.cancel")){
|
||||
@Override
|
||||
public void action(){
|
||||
ZC.setHiddenItems(originalItems);
|
||||
PaletteManager.init();
|
||||
ZC.closeRestrictDialog();
|
||||
}
|
||||
};
|
||||
myJButton factorybtn=new myJButton(150, Global.Loc("restrict.factory")){
|
||||
@Override
|
||||
public void action(){
|
||||
ZC.initRestrictedHiddenItemsFromFactorySettings();
|
||||
panel.initAllStates();
|
||||
}
|
||||
};
|
||||
PaletteManager.fixsize(this, RestrictContainer.getContainerWidth(), 30);
|
||||
JEricPanel jp=new JEricPanel();
|
||||
jp.setOpaque(false);
|
||||
jp.setAlignmentX(0.5f);
|
||||
jp.setAlignmentY(0.5f);
|
||||
|
||||
add(RestrictPanelIconsLine.margin(5));
|
||||
add(factorybtn);
|
||||
add(jp);
|
||||
add(cancelbtn);
|
||||
add(RestrictPanelIconsLine.margin(10));
|
||||
add(closebtn);
|
||||
add(RestrictPanelIconsLine.margin(5));
|
||||
}
|
||||
|
||||
public class myJButton extends JButton {
|
||||
|
||||
public myJButton(int w, String label) {
|
||||
super(label);
|
||||
setFocusable(false);
|
||||
setFont(new Font(Global.GlobalFont, 0, 12));
|
||||
setAlignmentX(0.5f);
|
||||
setAlignmentY(0.5f);
|
||||
setVerticalAlignment(SwingConstants.CENTER);
|
||||
PaletteManager.fixsize(this, w, 19);
|
||||
addMouseListener(new MouseAdapter() {
|
||||
@Override
|
||||
public void mouseClicked(MouseEvent e) {
|
||||
action();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void action() {
|
||||
}
|
||||
}
|
||||
}
|
||||
48
eric/restrict/RestrictContainerTitle.java
Normal file
48
eric/restrict/RestrictContainerTitle.java
Normal file
|
|
@ -0,0 +1,48 @@
|
|||
/*
|
||||
* To change this template, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package eric.restrict;
|
||||
|
||||
import eric.GUI.palette.PaletteManager;
|
||||
import eric.GUI.themes;
|
||||
import java.awt.Color;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.Font;
|
||||
import java.awt.Graphics;
|
||||
import java.awt.Image;
|
||||
import javax.swing.BoxLayout;
|
||||
import javax.swing.JLabel;
|
||||
import eric.JEricPanel;
|
||||
import javax.swing.SwingConstants;
|
||||
import rene.gui.Global;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author erichake
|
||||
*/
|
||||
public class RestrictContainerTitle extends JEricPanel {
|
||||
|
||||
@Override
|
||||
public void paintComponent(Graphics g){
|
||||
Dimension d=getSize();
|
||||
g.setColor(new Color(230,230,230));
|
||||
g.fillRect(0, 0, d.width, d.height);
|
||||
g.setColor(new Color(130,130,130));
|
||||
g.drawLine(0, d.height-1, d.width, d.height-1);
|
||||
}
|
||||
|
||||
public RestrictContainerTitle() {
|
||||
setLayout(new BoxLayout(this, BoxLayout.X_AXIS));
|
||||
JLabel label=new JLabel(Global.Loc("restrict.title"));
|
||||
// setBackground(new Color(230,230,230));
|
||||
PaletteManager.fixsize(this, RestrictContainer.getContainerWidth(), 25);
|
||||
PaletteManager.fixsize(label, RestrictContainer.getContainerWidth(), 25);
|
||||
label.setHorizontalAlignment(SwingConstants.CENTER);
|
||||
label.setVerticalAlignment(SwingConstants.CENTER);
|
||||
label.setFont(new Font(Global.GlobalFont,0,12));
|
||||
add(label);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
174
eric/restrict/RestrictItems.java
Normal file
174
eric/restrict/RestrictItems.java
Normal file
|
|
@ -0,0 +1,174 @@
|
|||
/*
|
||||
* To change this template, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package eric.restrict;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import rene.gui.Global;
|
||||
import rene.util.xml.XmlWriter;
|
||||
import rene.zirkel.ZirkelCanvas;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author erichake
|
||||
*/
|
||||
public class RestrictItems {
|
||||
|
||||
private ZirkelCanvas ZC;
|
||||
private ArrayList<String> hiddenItems=new ArrayList<String>();
|
||||
public static final String DISK="z_disk";
|
||||
public static final String EDIT="z_edit";
|
||||
public static final String GEOM="z_geom";
|
||||
public static final String ASPECT="z_aspect";
|
||||
public static final String FUNC="z_func";
|
||||
public static final String TEST="z_test";
|
||||
public static final String CTRL="z_ctrl";
|
||||
public static final String GRID="z_grid";
|
||||
public static final String HIST="z_hist";
|
||||
public static final String BACK="z_back";
|
||||
public static final String SIZE="z_size";
|
||||
public static final String PREC="z_prec";
|
||||
public static final String MENU="x_menu"; // for menu bar
|
||||
public static final String MCRP="x_macr"; // for macro panel
|
||||
public static final String HISTP="x_hist"; // for history panel
|
||||
public static final String HLPP="x_help"; // for help panel
|
||||
public static final String LMCR="x_lmcr"; // for library macros
|
||||
public static String[] geom_icns, disk_icns, edit_icns, func_icns, test_icns, control_icns,
|
||||
grid_icns, history_icns, back_icns, size_icns, prec_icns;
|
||||
public static String standardRestrictedHiddenItems="save,copy,exportpng,exporteps,exportsvg,exportpdf,edit,animate,grid,z_disk,new,load,bi_trans,intersection,fixedsegment,vector,quadric,image3,z_func,tracker,objecttracker,locus,bi_function_u,function,equationxy,z_test,bi_t_align,bi_t_para,bi_t_perp,bi_t_equi,bi_t_app,bi_t_conf,z_ctrl,ctrl_edit,ctrl_slider,ctrl_popup,ctrl_chkbox,ctrl_txtfield,ctrl_button,z_grid,z_hist,z_back,z_size,z_prec";
|
||||
|
||||
public RestrictItems(ZirkelCanvas zc) {
|
||||
ZC=zc;
|
||||
}
|
||||
|
||||
public boolean isRestricted() {
|
||||
return (hiddenItems.size()>0);
|
||||
}
|
||||
|
||||
public boolean isHidden(String s) {
|
||||
for (int i=0; i<hiddenItems.size(); i++) {
|
||||
if (s.equals(hiddenItems.get(i))) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public void add(String s) {
|
||||
if (!isHidden(s)) {
|
||||
hiddenItems.add(s);
|
||||
}
|
||||
}
|
||||
|
||||
public void remove(String s) {
|
||||
hiddenItems.remove(s);
|
||||
}
|
||||
|
||||
public ArrayList<String> get() {
|
||||
return hiddenItems;
|
||||
}
|
||||
|
||||
public void set(String items) {
|
||||
hiddenItems=new ArrayList<String>(Arrays.asList(items.split(",")));
|
||||
}
|
||||
|
||||
public void set(ArrayList<String> items) {
|
||||
hiddenItems.clear();
|
||||
for (int i=0; i<items.size(); i++) {
|
||||
hiddenItems.add(items.get(i));
|
||||
}
|
||||
}
|
||||
|
||||
public void initRestrictedHiddenItemsFromFactorySettings() {
|
||||
if (hiddenItems.size()>0) {
|
||||
hiddenItems=new ArrayList<String>(Arrays.asList(standardRestrictedHiddenItems.split(",")));
|
||||
}
|
||||
}
|
||||
|
||||
public void initRestrictedHiddenItems() {
|
||||
if (hiddenItems.size()==0) {
|
||||
String items=Global.getParameter("standardRestrictedHiddenItems", standardRestrictedHiddenItems);
|
||||
if ("".equals(items)) {
|
||||
hiddenItems=new ArrayList<String>();
|
||||
} else {
|
||||
hiddenItems=new ArrayList<String>(Arrays.asList(items.split(",")));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void setStandardRestrictedItems() {
|
||||
if (hiddenItems.size()>0) {
|
||||
Global.setParameter("standardRestrictedHiddenItems", getHiddenItems());
|
||||
}
|
||||
}
|
||||
|
||||
public String getHiddenItems() {
|
||||
// join hiddenItems ArrayList in a string with comma separator.
|
||||
// A shame there is no such a method in java !
|
||||
String items=hiddenItems.toString();
|
||||
items=items.replace(" ", "");
|
||||
items=items.replace("[", "");
|
||||
items=items.replace("]", "");
|
||||
return items;
|
||||
}
|
||||
|
||||
public void printArgs(final XmlWriter xml) {
|
||||
if (hiddenItems.size()>0) {
|
||||
xml.startTagStart("RestrictedSession");
|
||||
xml.printArg("HiddenIcons", getHiddenItems());
|
||||
xml.finishTagNewLine();
|
||||
}
|
||||
}
|
||||
|
||||
/************************************************************
|
||||
* Initialisation of static parameters from PaletteManager :
|
||||
* **********************************************************/
|
||||
public static void init_disk_icns(String icns[]) {
|
||||
disk_icns=icns;
|
||||
}
|
||||
|
||||
public static void init_edit_icns(String icns[]) {
|
||||
edit_icns=icns;
|
||||
}
|
||||
|
||||
public static void init_geom_icns(String icns[]) {
|
||||
geom_icns=icns;
|
||||
}
|
||||
|
||||
public static void init_func_icns(String icns[]) {
|
||||
func_icns=icns;
|
||||
}
|
||||
|
||||
public static void init_test_icns(String icns[]) {
|
||||
test_icns=icns;
|
||||
}
|
||||
|
||||
public static void init_control_icns(String icns[]) {
|
||||
control_icns=icns;
|
||||
}
|
||||
|
||||
public static void init_grid_icns(String icns[]) {
|
||||
grid_icns=icns;
|
||||
}
|
||||
|
||||
public static void init_history_icns(String icns[]) {
|
||||
history_icns=icns;
|
||||
}
|
||||
|
||||
public static void init_back_icns(String icns[]) {
|
||||
back_icns=icns;
|
||||
}
|
||||
|
||||
public static void init_size_icns(String icns[]) {
|
||||
size_icns=icns;
|
||||
}
|
||||
|
||||
public static void init_prec_icns(String icns[]) {
|
||||
prec_icns=icns;
|
||||
}
|
||||
/********************
|
||||
* End Initialisation
|
||||
* ******************/
|
||||
}
|
||||
44
eric/restrict/RestrictNonPalettePreference.java
Normal file
44
eric/restrict/RestrictNonPalettePreference.java
Normal file
|
|
@ -0,0 +1,44 @@
|
|||
/*
|
||||
* To change this template, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package eric.restrict;
|
||||
|
||||
import eric.GUI.palette.PaletteManager;
|
||||
import eric.GUI.window.MenuBar;
|
||||
import eric.JZirkelCanvas;
|
||||
import rene.zirkel.ZirkelCanvas;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author erichake
|
||||
*/
|
||||
public class RestrictNonPalettePreference extends RestrictPanelLine {
|
||||
|
||||
String name;
|
||||
|
||||
public RestrictNonPalettePreference(String nme, String label) {
|
||||
super(label);
|
||||
name=nme;
|
||||
initState();
|
||||
}
|
||||
|
||||
public void initState() {
|
||||
ZirkelCanvas zc=JZirkelCanvas.getCurrentZC();
|
||||
if (zc!=null) {
|
||||
setSelected(!zc.isHiddenItem(name));
|
||||
}
|
||||
}
|
||||
|
||||
public void action() {
|
||||
ZirkelCanvas zc=JZirkelCanvas.getCurrentZC();
|
||||
if (zc!=null) {
|
||||
if (isSelected()) {
|
||||
zc.removeHiddenItem(name);
|
||||
} else {
|
||||
zc.addHiddenItem(name);
|
||||
}
|
||||
}
|
||||
PaletteManager.init();
|
||||
}
|
||||
}
|
||||
222
eric/restrict/RestrictPanel.java
Normal file
222
eric/restrict/RestrictPanel.java
Normal file
|
|
@ -0,0 +1,222 @@
|
|||
/*
|
||||
* To change this template, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
|
||||
package eric.restrict;
|
||||
|
||||
import eric.GUI.palette.PaletteManager;
|
||||
import java.util.ArrayList;
|
||||
import javax.swing.BorderFactory;
|
||||
import javax.swing.BoxLayout;
|
||||
import eric.JEricPanel;
|
||||
import javax.swing.JSeparator;
|
||||
import rene.gui.Global;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author erichake
|
||||
*/
|
||||
public class RestrictPanel extends JEricPanel{
|
||||
private static int W=400,H=1200,MARGINH=20,SMALLMARGINH=10;
|
||||
private ArrayList<RestrictPanelIconsLineTitle> iconslines=new ArrayList<RestrictPanelIconsLineTitle>();
|
||||
|
||||
private RestrictNonPalettePreference menu,macr,hist,help,lib_macros;
|
||||
|
||||
public RestrictPanel(){
|
||||
setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
|
||||
setBorder(BorderFactory.createEmptyBorder());
|
||||
setOpaque(false);
|
||||
PaletteManager.fixsize(this, W,H );
|
||||
|
||||
add(marginH(MARGINH));
|
||||
add(new RestrictPanelActiveLine(this, Global.Loc("restrict.activate")));
|
||||
add(marginH(MARGINH));
|
||||
add(new RestrictSeparator(SMALLMARGINH));
|
||||
add(new RestrictPanelComment());
|
||||
|
||||
|
||||
init_Disk_zone();
|
||||
init_Edit_zone();
|
||||
init_Construction_zone();
|
||||
init_Func_zone();
|
||||
init_Test_zone();
|
||||
init_Control_zone();
|
||||
init_Aspect_zone();
|
||||
init_Grid_zone();
|
||||
init_History_zone();
|
||||
init_Back_zone();
|
||||
init_Size_zone();
|
||||
init_Prec_zone();
|
||||
add(marginH(MARGINH));
|
||||
add(new RestrictSeparator(SMALLMARGINH));
|
||||
add(marginH(MARGINH));
|
||||
add(menu=new RestrictNonPalettePreference(RestrictItems.MENU,Global.Loc("restrict.menubar")));
|
||||
add(marginH(MARGINH));
|
||||
add(macr=new RestrictNonPalettePreference(RestrictItems.MCRP,Global.Loc("restrict.macropanel")));
|
||||
add(marginH(MARGINH));
|
||||
add(hist=new RestrictNonPalettePreference(RestrictItems.HISTP,Global.Loc("restrict.historypanel")));
|
||||
add(marginH(MARGINH));
|
||||
add(help=new RestrictNonPalettePreference(RestrictItems.HLPP,Global.Loc("restrict.helppanel")));
|
||||
add(marginH(MARGINH));
|
||||
add(lib_macros=new RestrictNonPalettePreference(RestrictItems.LMCR, Global.Loc("restrict.librarymacros")));
|
||||
}
|
||||
|
||||
public static int getPanelWidth(){
|
||||
return W;
|
||||
}
|
||||
|
||||
public void setSelectAll(boolean b){
|
||||
for (int i=0;i<iconslines.size();i++){
|
||||
iconslines.get(i).setSelected(true,b);
|
||||
}
|
||||
if (menu!=null) menu.setSelected(b);
|
||||
if (macr!=null) macr.setSelected(b);
|
||||
if (hist!=null) hist.setSelected(b);
|
||||
if (help!=null) help.setSelected(b);
|
||||
if (lib_macros!=null) lib_macros.setSelected(b);
|
||||
}
|
||||
public void setEnabledAll(boolean b){
|
||||
for (int i=0;i<iconslines.size();i++){
|
||||
iconslines.get(i).setEnabled(b);
|
||||
iconslines.get(i).setEnabledIcons(b);
|
||||
}
|
||||
if (menu!=null) menu.setEnabled(b);
|
||||
if (macr!=null) macr.setEnabled(b);
|
||||
if (hist!=null) hist.setEnabled(b);
|
||||
if (help!=null) help.setEnabled(b);
|
||||
if (lib_macros!=null) lib_macros.setEnabled(b);
|
||||
}
|
||||
|
||||
public void initAllStates(){
|
||||
for (int i=0;i<iconslines.size();i++){
|
||||
iconslines.get(i).initIconsState();
|
||||
iconslines.get(i).initState();
|
||||
}
|
||||
if (menu!=null) menu.initState();
|
||||
if (macr!=null) macr.initState();
|
||||
if (hist!=null) hist.initState();
|
||||
if (help!=null) help.initState();
|
||||
if (lib_macros!=null) lib_macros.initState();
|
||||
}
|
||||
|
||||
static JEricPanel marginH() {
|
||||
return marginH(MARGINH);
|
||||
}
|
||||
|
||||
static JEricPanel marginH(int h) {
|
||||
JEricPanel mypan=new JEricPanel();
|
||||
PaletteManager.fixsize(mypan, 1, h);
|
||||
mypan.setLayout(new javax.swing.BoxLayout(mypan, javax.swing.BoxLayout.X_AXIS));
|
||||
mypan.setAlignmentX(0F);
|
||||
mypan.setAlignmentY(0F);
|
||||
mypan.setOpaque(false);
|
||||
mypan.setFocusable(false);
|
||||
return mypan;
|
||||
}
|
||||
|
||||
|
||||
public void init_Disk_zone(){
|
||||
RestrictPanelIconsLineTitle title=new RestrictPanelIconsLineTitle(RestrictItems.DISK,Global.Loc("palette.file")+" :");
|
||||
RestrictPanelIconsLine line=new RestrictPanelIconsLine(title,RestrictItems.disk_icns);
|
||||
add(marginH());
|
||||
add(title);
|
||||
add(line);
|
||||
iconslines.add(title);
|
||||
}
|
||||
|
||||
public void init_Edit_zone(){
|
||||
RestrictPanelIconsLineTitle title=new RestrictPanelIconsLineTitle(RestrictItems.EDIT,Global.Loc("palette.edit")+" :");
|
||||
RestrictPanelIconsLine line=new RestrictPanelIconsLine(title,RestrictItems.edit_icns);
|
||||
add(marginH());
|
||||
add(title);
|
||||
add(line);
|
||||
iconslines.add(title);
|
||||
}
|
||||
|
||||
|
||||
public void init_Construction_zone(){
|
||||
RestrictPanelIconsLineTitle title=new RestrictPanelIconsLineTitle(RestrictItems.GEOM,Global.Loc("palette.construction")+" :");
|
||||
RestrictPanelIconsLine line=new RestrictPanelIconsLine(title,RestrictItems.geom_icns);
|
||||
add(marginH());
|
||||
add(title);
|
||||
add(line);
|
||||
iconslines.add(title);
|
||||
}
|
||||
|
||||
public void init_Aspect_zone(){
|
||||
RestrictPanelIconsLineTitle title=new RestrictPanelIconsLineTitle(RestrictItems.ASPECT,Global.Loc("palette.aspect"));
|
||||
add(marginH(SMALLMARGINH));
|
||||
add(title);
|
||||
iconslines.add(title);
|
||||
}
|
||||
|
||||
public void init_Func_zone(){
|
||||
RestrictPanelIconsLineTitle title=new RestrictPanelIconsLineTitle(RestrictItems.FUNC,Global.Loc("palette.function")+" :");
|
||||
RestrictPanelIconsLine line=new RestrictPanelIconsLine(title,RestrictItems.func_icns);
|
||||
add(marginH());
|
||||
add(title);
|
||||
add(line);
|
||||
iconslines.add(title);
|
||||
}
|
||||
|
||||
public void init_Test_zone(){
|
||||
RestrictPanelIconsLineTitle title=new RestrictPanelIconsLineTitle(RestrictItems.TEST,Global.Loc("palette.test")+" :");
|
||||
RestrictPanelIconsLine line=new RestrictPanelIconsLine(title,RestrictItems.test_icns);
|
||||
add(marginH());
|
||||
add(title);
|
||||
add(line);
|
||||
iconslines.add(title);
|
||||
}
|
||||
|
||||
public void init_Control_zone(){
|
||||
RestrictPanelIconsLineTitle title=new RestrictPanelIconsLineTitle(RestrictItems.CTRL,Global.Loc("palette.controls")+" :");
|
||||
RestrictPanelIconsLine line=new RestrictPanelIconsLine(title,RestrictItems.control_icns);
|
||||
add(marginH());
|
||||
add(title);
|
||||
add(line);
|
||||
iconslines.add(title);
|
||||
}
|
||||
|
||||
public void init_Grid_zone(){
|
||||
RestrictPanelIconsLineTitle title=new RestrictPanelIconsLineTitle(RestrictItems.GRID,Global.Loc("palette.grid"));
|
||||
add(marginH(SMALLMARGINH));
|
||||
add(title);
|
||||
iconslines.add(title);
|
||||
}
|
||||
|
||||
public void init_History_zone(){
|
||||
RestrictPanelIconsLineTitle title=new RestrictPanelIconsLineTitle(RestrictItems.HIST,Global.Loc("palette.history"));
|
||||
add(marginH(SMALLMARGINH));
|
||||
add(title);
|
||||
iconslines.add(title);
|
||||
}
|
||||
|
||||
public void init_Back_zone(){
|
||||
RestrictPanelIconsLineTitle title=new RestrictPanelIconsLineTitle(RestrictItems.BACK,Global.Loc("palette.colors"));
|
||||
add(marginH(SMALLMARGINH));
|
||||
add(title);
|
||||
iconslines.add(title);
|
||||
}
|
||||
|
||||
public void init_Size_zone(){
|
||||
RestrictPanelIconsLineTitle title=new RestrictPanelIconsLineTitle(RestrictItems.SIZE,Global.Loc("palette.sizes"));
|
||||
add(marginH(SMALLMARGINH));
|
||||
add(title);
|
||||
iconslines.add(title);
|
||||
}
|
||||
|
||||
public void init_Prec_zone(){
|
||||
RestrictPanelIconsLineTitle title=new RestrictPanelIconsLineTitle(RestrictItems.PREC,Global.Loc("palette.prec"));
|
||||
add(marginH(SMALLMARGINH));
|
||||
add(title);
|
||||
iconslines.add(title);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
49
eric/restrict/RestrictPanelActiveLine.java
Normal file
49
eric/restrict/RestrictPanelActiveLine.java
Normal file
|
|
@ -0,0 +1,49 @@
|
|||
/*
|
||||
* To change this template, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package eric.restrict;
|
||||
|
||||
import eric.JZirkelCanvas;
|
||||
import javax.swing.SwingConstants;
|
||||
import javax.swing.SwingUtilities;
|
||||
import rene.zirkel.ZirkelCanvas;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author erichake
|
||||
*/
|
||||
public class RestrictPanelActiveLine extends RestrictPanelLine {
|
||||
|
||||
private RestrictPanel panel;
|
||||
|
||||
public RestrictPanelActiveLine(RestrictPanel parent, String label) {
|
||||
super(label);
|
||||
setHorizontalAlignment(SwingConstants.CENTER);
|
||||
panel=parent;
|
||||
ZirkelCanvas zc=JZirkelCanvas.getCurrentZC();
|
||||
if (zc!=null) {
|
||||
setSelected(zc.isRestricted());
|
||||
}
|
||||
SwingUtilities.invokeLater(new Runnable() {
|
||||
|
||||
public void run() {
|
||||
panel.setEnabledAll(isSelected());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void action() {
|
||||
panel.setEnabledAll(true);
|
||||
if (isSelected()) {
|
||||
ZirkelCanvas zc=JZirkelCanvas.getCurrentZC();
|
||||
if (zc!=null) {
|
||||
zc.initStandardRestrictedHiddenItems();
|
||||
}
|
||||
panel.initAllStates();
|
||||
}else{
|
||||
panel.setSelectAll(true);
|
||||
}
|
||||
panel.setEnabledAll(isSelected());
|
||||
}
|
||||
}
|
||||
29
eric/restrict/RestrictPanelComment.java
Normal file
29
eric/restrict/RestrictPanelComment.java
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
/*
|
||||
* To change this template, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package eric.restrict;
|
||||
|
||||
import eric.GUI.palette.PaletteManager;
|
||||
import java.awt.Color;
|
||||
import java.awt.Font;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.SwingUtilities;
|
||||
import rene.gui.Global;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author erichake
|
||||
*/
|
||||
public class RestrictPanelComment extends JLabel {
|
||||
|
||||
public RestrictPanelComment() {
|
||||
super("<html><center>"+Global.Loc("restrict.comment")+"</center></html>");
|
||||
setFont(new Font(Global.GlobalFont,0,12));
|
||||
setForeground(Color.darkGray);
|
||||
PaletteManager.fixsize(this, RestrictContainer.getContainerWidth(), 60);
|
||||
setHorizontalTextPosition(SwingUtilities.CENTER);
|
||||
setHorizontalAlignment(SwingUtilities.CENTER);
|
||||
setVerticalAlignment(SwingUtilities.CENTER);
|
||||
}
|
||||
}
|
||||
55
eric/restrict/RestrictPanelFlowIcons.java
Normal file
55
eric/restrict/RestrictPanelFlowIcons.java
Normal file
|
|
@ -0,0 +1,55 @@
|
|||
/*
|
||||
* To change this template, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package eric.restrict;
|
||||
|
||||
import eric.GUI.palette.PaletteManager;
|
||||
import eric.GUI.themes;
|
||||
import java.awt.Color;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.FlowLayout;
|
||||
import java.awt.Graphics;
|
||||
import java.awt.Graphics2D;
|
||||
import javax.swing.BorderFactory;
|
||||
import eric.JEricPanel;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author erichake
|
||||
*/
|
||||
public class RestrictPanelFlowIcons extends JEricPanel {
|
||||
|
||||
public RestrictPanelFlowIcons() {
|
||||
setLayout(new FlowLayout(FlowLayout.LEFT, 0, 0));
|
||||
// setBorder(BorderFactory.createEmptyBorder());
|
||||
// setOpaque(false);
|
||||
setBackground(new Color(218,228,242));
|
||||
setBorder(BorderFactory.createEtchedBorder());
|
||||
setAlignmentX(0.0f);
|
||||
setAlignmentY(0.0f);
|
||||
}
|
||||
|
||||
public void addIcons(RestrictPanelIconsLineTitle title,String[] icns) {
|
||||
for (int i=0; i<icns.length; i++) {
|
||||
addIcon(title,icns[i]);
|
||||
}
|
||||
fixsize();
|
||||
}
|
||||
|
||||
public void addIcon(RestrictPanelIconsLineTitle title,String icn) {
|
||||
RestrictPanelIcon restrictIcon=new RestrictPanelIcon(title, icn);
|
||||
add(restrictIcon);
|
||||
title.addIcon(restrictIcon);
|
||||
}
|
||||
|
||||
public void fixsize() {
|
||||
if (getComponentCount()==0) {
|
||||
return;
|
||||
}
|
||||
RestrictPanelIcon ri=(RestrictPanelIcon) getComponent(0);
|
||||
int w=ri.getSize().width*themes.getPaletteIconPerRow();
|
||||
int h=ri.getSize().height*(1+(getComponentCount()-1)/themes.getPaletteIconPerRow());
|
||||
PaletteManager.fixsize(this, w+10, h+10);
|
||||
}
|
||||
}
|
||||
112
eric/restrict/RestrictPanelIcon.java
Normal file
112
eric/restrict/RestrictPanelIcon.java
Normal file
|
|
@ -0,0 +1,112 @@
|
|||
/*
|
||||
* To change this template, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package eric.restrict;
|
||||
|
||||
import eric.GUI.palette.PaletteManager;
|
||||
import eric.GUI.themes;
|
||||
import eric.GUI.windowComponent;
|
||||
import eric.JZirkelCanvas;
|
||||
import java.awt.Graphics;
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.Image;
|
||||
import java.awt.event.ItemEvent;
|
||||
import java.awt.event.ItemListener;
|
||||
import java.awt.event.MouseEvent;
|
||||
import java.awt.event.MouseListener;
|
||||
import java.awt.image.FilteredImageSource;
|
||||
import java.awt.image.ImageFilter;
|
||||
import javax.swing.GrayFilter;
|
||||
import javax.swing.ImageIcon;
|
||||
import javax.swing.JCheckBox;
|
||||
import javax.swing.SwingConstants;
|
||||
import rene.zirkel.ZirkelCanvas;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author erichake
|
||||
*/
|
||||
public class RestrictPanelIcon extends JCheckBox implements MouseListener, ItemListener {
|
||||
|
||||
private Image image;
|
||||
private String name;
|
||||
private RestrictPanelIconsLineTitle title;
|
||||
private int W=60, H=32, MARGINW=18;
|
||||
private static boolean select=false;
|
||||
|
||||
@Override
|
||||
public void paintComponent(Graphics g) {
|
||||
|
||||
final Graphics2D g2=windowComponent.getGraphics2D(g);
|
||||
if (isEnabled()) {
|
||||
g2.drawImage(image, MARGINW, 0, this);
|
||||
} else {
|
||||
final ImageFilter filter=new GrayFilter(true, 50);
|
||||
final Image disImage=createImage(new FilteredImageSource(image.getSource(), filter));
|
||||
final ImageIcon myicn=new ImageIcon(disImage);
|
||||
g2.drawImage(myicn.getImage(), MARGINW, 0, this);
|
||||
}
|
||||
super.paintComponent(g);
|
||||
}
|
||||
|
||||
public RestrictPanelIcon(RestrictPanelIconsLineTitle ttle, String nme) {
|
||||
name=nme;
|
||||
title=ttle;
|
||||
PaletteManager.fixsize(this, W, H);
|
||||
image=themes.getPaletteImage(nme);
|
||||
putClientProperty("JComponent.sizeVariant", "mini");
|
||||
setFocusable(false);
|
||||
setOpaque(false);
|
||||
setVerticalAlignment(SwingConstants.BOTTOM);
|
||||
addMouseListener(this);
|
||||
addItemListener(this);
|
||||
initState();
|
||||
}
|
||||
|
||||
public void initState() {
|
||||
ZirkelCanvas zc=JZirkelCanvas.getCurrentZC();
|
||||
if (zc!=null) {
|
||||
setSelected(!zc.isHiddenItem(name));
|
||||
}
|
||||
}
|
||||
|
||||
public void mouseClicked(MouseEvent e) {
|
||||
}
|
||||
|
||||
public void mousePressed(MouseEvent e) {
|
||||
if (e.getButton()==MouseEvent.BUTTON3) {
|
||||
select=!isSelected();
|
||||
setSelected(select);
|
||||
}
|
||||
}
|
||||
|
||||
public void mouseReleased(MouseEvent e) {
|
||||
}
|
||||
|
||||
public void mouseEntered(MouseEvent e) {
|
||||
if (e.getButton()==MouseEvent.BUTTON3) {
|
||||
setSelected(select);
|
||||
}
|
||||
}
|
||||
|
||||
public void mouseExited(MouseEvent e) {
|
||||
}
|
||||
|
||||
public void itemStateChanged(ItemEvent e) {
|
||||
ZirkelCanvas zc=JZirkelCanvas.getCurrentZC();
|
||||
if (zc!=null) {
|
||||
if (isSelected()) {
|
||||
zc.removeHiddenItem(name);
|
||||
if (!title.isSelected()) {
|
||||
title.setSelected(false, true);
|
||||
}
|
||||
} else {
|
||||
zc.addHiddenItem(name);
|
||||
title.uncheckIfAlone();
|
||||
}
|
||||
}
|
||||
|
||||
PaletteManager.init();
|
||||
}
|
||||
}
|
||||
41
eric/restrict/RestrictPanelIconsLine.java
Normal file
41
eric/restrict/RestrictPanelIconsLine.java
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
/*
|
||||
* To change this template, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package eric.restrict;
|
||||
|
||||
import eric.GUI.palette.PaletteManager;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.FlowLayout;
|
||||
import javax.swing.BoxLayout;
|
||||
import eric.JEricPanel;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author erichake
|
||||
*/
|
||||
public class RestrictPanelIconsLine extends JEricPanel {
|
||||
private int margin=65;
|
||||
|
||||
public RestrictPanelIconsLine(RestrictPanelIconsLineTitle title,String[] icns) {
|
||||
setLayout(new BoxLayout(this, BoxLayout.X_AXIS));
|
||||
setAlignmentX(0.0f);
|
||||
setAlignmentY(0.0f);
|
||||
add(margin(margin));
|
||||
setOpaque(false);
|
||||
RestrictPanelFlowIcons line=new RestrictPanelFlowIcons();
|
||||
line.addIcons(title, icns);
|
||||
add(line);
|
||||
}
|
||||
|
||||
static JEricPanel margin(int w) {
|
||||
JEricPanel mypan=new JEricPanel();
|
||||
PaletteManager.fixsize(mypan, w, 1);
|
||||
mypan.setLayout(new javax.swing.BoxLayout(mypan, javax.swing.BoxLayout.X_AXIS));
|
||||
mypan.setAlignmentX(0.5F);
|
||||
mypan.setAlignmentY(0.5F);
|
||||
mypan.setOpaque(false);
|
||||
mypan.setFocusable(false);
|
||||
return mypan;
|
||||
}
|
||||
}
|
||||
104
eric/restrict/RestrictPanelIconsLineTitle.java
Normal file
104
eric/restrict/RestrictPanelIconsLineTitle.java
Normal file
|
|
@ -0,0 +1,104 @@
|
|||
/*
|
||||
* To change this template, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package eric.restrict;
|
||||
|
||||
import eric.GUI.palette.PaletteManager;
|
||||
import eric.JZirkelCanvas;
|
||||
import java.awt.Font;
|
||||
import java.awt.event.ItemEvent;
|
||||
import java.awt.event.ItemListener;
|
||||
import java.awt.event.MouseAdapter;
|
||||
import java.awt.event.MouseEvent;
|
||||
import java.util.ArrayList;
|
||||
import javax.swing.JCheckBox;
|
||||
import rene.gui.Global;
|
||||
import rene.zirkel.ZirkelCanvas;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author erichake
|
||||
*/
|
||||
public class RestrictPanelIconsLineTitle extends RestrictPanelLine {
|
||||
|
||||
private String name;
|
||||
private ArrayList<RestrictPanelIcon> icons=new ArrayList<RestrictPanelIcon>();
|
||||
|
||||
public RestrictPanelIconsLineTitle(String nme, String label) {
|
||||
super(label);
|
||||
name=nme;
|
||||
addMouseListener(new MouseAdapter() {
|
||||
|
||||
@Override
|
||||
public void mouseClicked(MouseEvent e) {
|
||||
setSelectedIcons(isSelected());
|
||||
}
|
||||
});
|
||||
initState();
|
||||
}
|
||||
|
||||
public void initState() {
|
||||
ZirkelCanvas zc=JZirkelCanvas.getCurrentZC();
|
||||
if (zc!=null) {
|
||||
setSelected(!zc.isHiddenItem(name));
|
||||
if (!isSelected()) {
|
||||
setSelectedIcons(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void initIconsState() {
|
||||
for (int i=0; i<icons.size(); i++) {
|
||||
icons.get(i).initState();
|
||||
}
|
||||
}
|
||||
|
||||
public void addIcon(RestrictPanelIcon icn) {
|
||||
icons.add(icn);
|
||||
}
|
||||
|
||||
public void setSelected(boolean groupSelect, boolean sel) {
|
||||
setSelected(sel);
|
||||
if (groupSelect) {
|
||||
setSelectedIcons(sel);
|
||||
}
|
||||
}
|
||||
|
||||
public void uncheckIfAlone() {
|
||||
if (isSelected()) {
|
||||
boolean b=false;
|
||||
for (int i=0; i<icons.size(); i++) {
|
||||
b=b||icons.get(i).isSelected();
|
||||
}
|
||||
if (!b) {
|
||||
setSelected(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void setSelectedIcons(boolean b) {
|
||||
for (int i=0; i<icons.size(); i++) {
|
||||
icons.get(i).setSelected(b);
|
||||
}
|
||||
}
|
||||
|
||||
public void setEnabledIcons(boolean b) {
|
||||
for (int i=0; i<icons.size(); i++) {
|
||||
icons.get(i).setEnabled(b);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void action() {
|
||||
ZirkelCanvas zc=JZirkelCanvas.getCurrentZC();
|
||||
if (zc!=null) {
|
||||
if (isSelected()) {
|
||||
zc.removeHiddenItem(name);
|
||||
} else {
|
||||
zc.addHiddenItem(name);
|
||||
}
|
||||
}
|
||||
PaletteManager.init();
|
||||
}
|
||||
}
|
||||
39
eric/restrict/RestrictPanelLine.java
Normal file
39
eric/restrict/RestrictPanelLine.java
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
/*
|
||||
* To change this template, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package eric.restrict;
|
||||
|
||||
import eric.GUI.palette.PaletteManager;
|
||||
import java.awt.Font;
|
||||
import java.awt.event.ItemEvent;
|
||||
import java.awt.event.ItemListener;
|
||||
import javax.swing.JCheckBox;
|
||||
import javax.swing.SwingConstants;
|
||||
import rene.gui.Global;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author erichake
|
||||
*/
|
||||
public class RestrictPanelLine extends JCheckBox implements ItemListener {
|
||||
|
||||
public RestrictPanelLine(String label) {
|
||||
super(label);
|
||||
setAlignmentX(0.0f);
|
||||
setAlignmentY(0.0f);
|
||||
setFocusable(false);
|
||||
setOpaque(false);
|
||||
setFont(new Font(Global.GlobalFont,0,12));
|
||||
addItemListener(this);
|
||||
PaletteManager.fixsize(this, RestrictContainer.getContainerWidth(), 20);
|
||||
|
||||
}
|
||||
|
||||
public void action() {
|
||||
}
|
||||
|
||||
public void itemStateChanged(ItemEvent e) {
|
||||
action();
|
||||
}
|
||||
}
|
||||
31
eric/restrict/RestrictSeparator.java
Normal file
31
eric/restrict/RestrictSeparator.java
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
/*
|
||||
* To change this template, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
|
||||
package eric.restrict;
|
||||
|
||||
import eric.GUI.palette.PaletteManager;
|
||||
import javax.swing.BoxLayout;
|
||||
import eric.JEricPanel;
|
||||
import javax.swing.JSeparator;
|
||||
import javax.swing.SwingConstants;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author erichake
|
||||
*/
|
||||
public class RestrictSeparator extends JEricPanel{
|
||||
public RestrictSeparator(int h){
|
||||
super();
|
||||
setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
|
||||
setAlignmentX(0.0f);
|
||||
setAlignmentY(0.0f);
|
||||
setOpaque(false);
|
||||
// setOrientation(SwingConstants.HORIZONTAL);
|
||||
PaletteManager.fixsize(this, RestrictContainer.getContainerWidth(), h);
|
||||
JSeparator sep=new JSeparator();
|
||||
PaletteManager.fixsize(sep, RestrictContainer.getContainerWidth()-100, h);
|
||||
add(sep);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue