proppanel.java
来自「一个简单的visio程序。」· Java 代码 · 共 1,380 行 · 第 1/3 页
JAVA
1,380 行
{
pointcount = (int)(mouseclickpoint)/16;
}
return (pointcount <= 0 ? 0 : (int)(mouseclickpoint)/16);
}
String currentname = "";
private void Label0MouseClicked(MouseEvent e)
{
int l = getCurrentView(e) + getStart();
currentRow = l;
int currentview = getCurrentView(e);
if(l > properlength-1)
return;
if (views[l] == null)
return;
if(isVisibelView == views[l] && views[l].isVisible())
return;
Object s[] = (Object[])pTab.get(""+currentRow);
String name = (String)s[0];
Object val = wrapper.getPropValue(((Integer)s[1]).intValue());
((PropertyEditor)s[3]).setValue(val);
try
{
Dimension dim = getSize();
Insets pins = getInsets();
int width = dim.width - pins.left - pins.right;
int insets = 0;
if(scrollbar.isVisible())
{
insets = wodd+1+scrollwidth;
}
else
{
insets = wodd+1;
}
if(views[l] instanceof PropTextbox)
{
views[l].setBounds(101+getAddLength()+wodd-scrollwidth-8, rowheight*currentview+hodd+1, width - 101 - getAddLength()-insets+scrollwidth+6, 15);
if (name.equalsIgnoreCase("scaleleft")
|| name.equalsIgnoreCase("scaletop")
|| name.equalsIgnoreCase("scaleheight")
|| name.equalsIgnoreCase("scalewidth"))
{
((PropTextbox)views[l]).setText(val.toString());
}
}
else if(views[l] instanceof PropChoice)
{
views[l].setBounds(101+getAddLength()+wodd-scrollwidth-8, rowheight*currentview+hodd, width - 101 - getAddLength()-insets+scrollwidth+6, 15);
}
else if(views[l] instanceof SubButton)
{
views[l].setBounds(width-insets-bwidth+1,rowheight*currentview+hodd,bwidth,rowheight);
}
else if(views[l] instanceof DropButton)
{
views[l].setBounds(width-insets-bwidth+1,rowheight*currentview+hodd,bwidth,rowheight);
}
else
{
System.err.println("views contains other control");
}
}
catch (Exception ex) { }
if(isVisibelView != null)
isVisibelView.setVisible(false);
isVisibelView = views[l];
ScrollMoveCount = 0;
views[l].setVisible(true);
if (name.toLowerCase().equalsIgnoreCase("recordsource")
|| name.toLowerCase().equalsIgnoreCase("datafield")
|| name.toLowerCase().equalsIgnoreCase("datasource")
|| name.toLowerCase().equalsIgnoreCase("listfield")
|| name.toLowerCase().equalsIgnoreCase("boundcolumn")
|| name.toLowerCase().equalsIgnoreCase("rowsource"))
{
this.propsheet.refreshPropValue(name.toLowerCase());
}
requestFocus();
Repaint();
currentname = name;
}
public void Currentrefresh(int i)
{
Object s[] = (Object[])pTab.get(""+i);
String name = (String)s[0];
Object value = wrapper.getPropValue(((Integer)s[1]).intValue());
// Don't try to set null values:
Class type = (Class)s[2];
PropertyEditor editor = ((PropertyEditor)s[3]);
if (value == null)
{
if ( type.toString().equalsIgnoreCase("class java.lang.String"))
{
value = "";
try
{
editor.setValue(value);
}
catch(Exception e)
{
System.out.println("Warning1 in Currentrefresh"+e);
}
}
}
else
{
if (name.equalsIgnoreCase("width")
|| name.equalsIgnoreCase("height")
|| name.equalsIgnoreCase("left")
|| name.equalsIgnoreCase("top"))
{
short smode = 1;
float Ivalue = 0;
try
{
Ivalue = Util.getFloatValue(value);
}
catch(Exception e)
{
System.out.println("Warning2 in Currentrefresh"+e);
}
Ivalue = this.propsheet.JAVAtoVB(Ivalue,name);
if((1-(Ivalue - (int)Ivalue))<0.001 && smode == 1)
{
Ivalue = (int)Ivalue + 1;
}
else if((Ivalue - (int)Ivalue)<0.01 && smode == 1)
{
Ivalue = (int)Ivalue;
}
if((Ivalue - (int)Ivalue) == 0)
{
PropTextbox st = (PropTextbox)views[i];
if (st == null) return;
st.setText(String.valueOf((int)Ivalue));
editor.setValue(new Integer((int)Ivalue));
}
else
{
PropTextbox st = (PropTextbox)views[i];
editor.setValue(new Float(Ivalue));
}
return;
}
else if(name.equalsIgnoreCase("x1")
|| name.equalsIgnoreCase("x2")
|| name.equalsIgnoreCase("y1")
|| name.equalsIgnoreCase("y2"))
{
short smode = 1;
float Ivalue = 0;
Ivalue = Util.getFloatValue(value);
Ivalue = this.propsheet.JAVAtoVB(Ivalue,name);
if((1-(Ivalue - (int)Ivalue))<0.001 && smode == 1)
{
Ivalue = (int)Ivalue + 1;
}
else if((Ivalue - (int)Ivalue)<0.01 && smode == 1){
Ivalue = (int)Ivalue;
}
if((Ivalue - (int)Ivalue) == 0)
{
PropTextbox st = (PropTextbox)views[i];
if (st == null) return;
st.setText(String.valueOf((int)Ivalue));
editor.setValue(new Integer((int)Ivalue));
}
else
{
PropTextbox st = (PropTextbox)views[i];
editor.setValue(new Float(Ivalue));
}
return;
}
else if((name.equalsIgnoreCase("rowheight")||name.equalsIgnoreCase("defcolwidth"))
&& type.toString().equalsIgnoreCase("float"))
{
short smode = 1;
float Ivalue = 0;
Ivalue = Util.getFloatValue(value);
Ivalue = this.propsheet.JAVAtoVB(Ivalue,name);
if((1-(Ivalue - (int)Ivalue))<0.001 && smode == 1)
{
Ivalue = (int)Ivalue + 1;
}
else if((Ivalue - (int)Ivalue)<0.01 && smode == 1)
{
Ivalue = (int)Ivalue;
}
if((Ivalue - (int)Ivalue) == 0)
{
PropTextbox st = (PropTextbox)views[i];
if (st == null) return;
st.setText(String.valueOf((int)Ivalue));
editor.setValue(new Integer((int)Ivalue));
}
else
{
PropTextbox st = (PropTextbox)views[i];
editor.setValue(new Float(Ivalue));
}
return;
}
else
{
try
{
editor.setValue(value);
if(views[i] instanceof PropTextbox)
{
PropTextbox st = (PropTextbox)views[i];
if (st == null) return;
st.setText(value.toString());
}
}
catch(Exception e)
{
System.out.println("Warning3 in Currentrefresh"+e);
}
}
}
}
/* ---------------------------------------- Event ----------------------------------------- */
/*--- Adjust Listener ----------------------------------------------------------------------*/
public void adjustmentValueChanged(AdjustmentEvent event)
{
ScrollMoveCount ++;
int visible = scrollbar.getVisibleAmount();
int min = scrollbar.getMinimum();
float value = (float)scrollbar.getValue();
float max = (float)(scrollbar.getMaximum()-16);
increaseunit = (int)((value/max)*((float)properlength)) - start;
start = (int)((value/max)*((float)properlength));
if(isVisibelView != null && isVisibelView.isVisible() && ScrollMoveCount == 1)
isVisibelView.setVisible(false);
valuechanged = true;
update(getGraphics());
}
/*-----------------------------------------------------------------------------------------*/
/*--- Mouse Listener ----------------------------------------------------------------------*/
public void mousePressed(MouseEvent e)
{
mousepressed = true;
Label0MouseClicked(e);
}
public void mouseReleased(MouseEvent e)
{
if(mousedragged)
{
mousedragged = false;
Label0MouseClicked(e);
}
}
public void mouseClicked(MouseEvent e)
{
// empty
}
public void mouseExited(MouseEvent e)
{
// empty
}
public void mouseEntered(MouseEvent e)
{
// empty
}
/*-----------------------------------------------------------------------------------------*/
/*--- Mouse Motion Listener ---------------------------------------------------------------*/
public void mouseMoved(MouseEvent e){}
public void mouseDragged(MouseEvent e)
{
mousedragged = true;
if(!scrollbar.isVisible() && (e.getY()-hodd)/16 <= properlength-1 && (e.getY()-hodd)/16 >= 0)
{
CurrentValue = (e.getY()-hodd)/16;
}
else if(scrollbar.isVisible())
{
CurrentValue = (e.getY()-hodd) < 0 ? -1 : (e.getY()-hodd)/16;
if(CurrentValue+2 > scrollbar.getVisibleAmount()/16)
{
CurrentValue = scrollbar.getVisibleAmount()/16-1;
}
if((CurrentValue+2 > scrollbar.getVisibleAmount()/16)
&& (start+CurrentValue) < properlength - 1)
{
start = start+1;
scrollbar.setValue((start+1)*16);
}
else if(scrollbar.getValue() > 15 && CurrentValue < 0 && start > 0)
{
start = start - 1;
scrollbar.setValue((start)*16);
}
else if((start+(e.getY()-hodd)/16) < properlength && (e.getY()-hodd)/16 >= 0)
{
CurrentValue = (e.getY()-hodd)/16;
}
}
if(isVisibelView != null && isVisibelView.isVisible())
isVisibelView.setVisible(false);
repaint();
}
/*-----------------------------------------------------------------------------------------*/
/*--- Key Listener ------------------------------------------------------------------------*/
public void keyPressed(KeyEvent event)
{
if (views == null) return;
keypressed = true;
int code = event.getKeyCode();
if (code == KeyEvent.VK_DOWN)
{
if(!scrollbar.isVisible() && CurrentValue < properlength-1)
{
CurrentValue = CurrentValue + 1;
}
else if(scrollbar.isVisible())
{
if(((CurrentValue+1) >= (scrollbar.getVisibleAmount()/16))
&& (start+CurrentValue) <= properlength - 2)
{
start = start+1;
scrollbar.setValue((start+1)*16);
}
else if((start+CurrentValue) < properlength - 1)
{
CurrentValue = CurrentValue + 1;
}
}
if(isVisibelView.isVisible())
isVisibelView.setVisible(false);
repaint();
}
else if(code == KeyEvent.VK_UP)
{
if(!scrollbar.isVisible() && CurrentValue > 0)
{
CurrentValue = CurrentValue - 1;
}
else if(scrollbar.isVisible())
{
if(scrollbar.getValue() > 15 && CurrentValue == 0 && start > 0)
{
start = start - 1;
scrollbar.setValue((start-1)*16);
scrollbar.setValue((start)*16);
}
else if(CurrentValue > 0)
{
CurrentValue = CurrentValue - 1;
}
}
if(isVisibelView.isVisible())
isVisibelView.setVisible(false);
repaint();
}
else if(code == KeyEvent.VK_DELETE)
{
if(views[currentRow] instanceof SubButton)
{
((SubButton)views[currentRow]).keyPressed(event);
}
}
else
{
// empty
}
Object s[] = (Object[])pTab.get(""+(CurrentValue+start));
currentname = (String)s[0];
}
public void keyTyped(KeyEvent event){}
public void keyReleased(KeyEvent event)
{
keyReleased = true;
}
/*-----------------------------------------------------------------------------------------*/
/*--- Component Listener ------------------------------------------------------------------*/
public void componentResized(ComponentEvent e)
{
componentresize = true;
scrollbar.setBounds(getSize().width-scrollwidth-wodd,hodd,scrollwidth,getSize().height-6);
scrollbar.setVisibleAmount(getSize().height - Hodd);
if((getSize().height - Hodd) > properlength*rowheight)
{
start = 0;
scrollbar.setVisible(false);
if(isVisibelView != null)
isVisibelView.setVisible(false);
update(getGraphics());
return;
}
else if((getSize().height-Hodd) < properlength*rowheight && !scrollbar.isVisible())
{
scrollbar.setVisible(true);
scrollbar.setMaximum((properlength+1)*16);
scrollbar.setMinimum(0);
scrollbar.setVisibleAmount(getSize().height - Hodd);
scrollbar.setBlockIncrement(rowheight*4);
scrollbar.setUnitIncrement(rowheight);
}
if((properlength - start)*rowheight < (getSize().height - Hodd) && scrollbar.isVisible())
{
start = start - (getSize().height - Hodd - (properlength - start)*rowheight)/rowheight;
}
if(isVisibelView != null)
isVisibelView.setVisible(false);
}
public void componentMoved(ComponentEvent e)
{
// empty
}
public void componentShown(ComponentEvent e)
{
// empty
}
public void componentHidden(ComponentEvent e)
{
// empty
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?