⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 imagefigure.java

📁 对eclipse gef进行封装,可以生成图形化编辑器
💻 JAVA
字号:
/*******************************************************************************
 * $Header: /cvsroot/EOS6/work_dir/niegy/com.primeton.studio.gef.ui/src/com/primeton/studio/gef/ui/figure/ImageFigure.java,v 1.2 2006/12/12 08:26:39 niegy Exp $
 * $Revision: 1.2 $
 * $Date: 2006/12/12 08:26:39 $
 *
 *==============================================================================
 *
 * Copyright (c) 2001-2006 Primeton Technologies, Ltd.
 * All rights reserved. 
 * 
 * Created on 2006-9-28
 *******************************************************************************/


package com.primeton.studio.gef.ui.figure;

import org.eclipse.draw2d.ColorConstants;
import org.eclipse.draw2d.Figure;
import org.eclipse.draw2d.Graphics;
import org.eclipse.draw2d.Label;
import org.eclipse.draw2d.XYLayout;
import org.eclipse.draw2d.geometry.Point;
import org.eclipse.draw2d.geometry.Rectangle;
import org.eclipse.swt.graphics.Image;

/**
 * TODO此处填写 class 信息
 *
 * @author niegy (mailto:niegy@primeton.com)
 */
/*
 * 修改历史
 * $Log: ImageFigure.java,v $
 * Revision 1.2  2006/12/12 08:26:39  niegy
 * 重构代码,实现一般图元的编辑框
 *
 * Revision 1.1  2006/12/11 08:36:29  niegy
 * 重构代码
 *
 * Revision 1.1  2006/11/17 03:15:13  niegy
 * create
 * 
 */
 public class ImageFigure extends Figure { 
    
    private Image fImage = null;   
    public ImageFigure(String name,boolean isShape){
        this.setBackgroundColor(ColorConstants.black);
        this.setLayoutManager(new XYLayout());  
    }
    
    public ImageFigure(Image image){
       this();
       fImage = image;
    } 
    
    public void addLabel(Label label){
    	this.add(label);
    }
    
    public ImageFigure(){
      this.setLayoutManager(new XYLayout());  
    }  
    
    public void setImage(Image iamge){
        fImage = iamge;
    }
    
    protected void paintFigure(Graphics g){
        if(fImage != null){
            Point p = getBounds().getLocation();
            Rectangle src = new Rectangle(fImage.getBounds().x,
                    fImage.getBounds().y,
                    fImage.getBounds().width,
                    fImage.getBounds().height);
            if (fImage != null)
                g.drawImage(fImage,src ,getBounds());
        }
        else{
        	g.setBackgroundColor(ColorConstants.red);
        	g.fillRectangle(getBounds());
            super.paintFigure(g);
        }
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -