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

📄 container.java

📁 java实现pplive
💻 JAVA
字号:
package com.moveShape;

import java.awt.Color;
import java.awt.Graphics;
import java.awt.Point;
import java.util.ArrayList;

public class Container implements Shape
{

	private ArrayList<Shape>  unit;
	private Point ULpoint,lrpoint;
	
	public Container()
	{
		this.unit=new ArrayList<Shape>();
		this.ULpoint=new Point();
		this.lrpoint=new Point();
	}
	
	public void changeColor(Color color, String colorName)
	{
		// TODO Auto-generated method stub
		for(Shape shape:unit)
		{
			
			shape.changeColor(color, colorName);
		}
	}

	public void deleteObserver(MyObserver observer)
	{
		// TODO Auto-generated method stub
		for(Shape shape:unit)
		{
			shape.deleteObserver(observer);
		}
	}

	public void draw(Graphics g)
	{
		// TODO Auto-generated method stub
		for(Shape shape:unit)
		{
			shape.draw(g);
		}
	}

	public boolean isInside(Point p)
	{ 
		boolean result=false;
		boolean temp=false;
		// TODO Auto-generated method stub
		for(Shape shape:unit)
		{
			
			temp=shape.isInside(p);
			
			if(temp)
			{
				result=true;
			}
		}
		if(result)
		{
			for(Shape shape:unit)
			{
				shape.setState(true);
			}
		}
		return result;
	}

	public void move(Point p)
	{
		// TODO Auto-generated method stub
		for(Shape shape:unit)
		{
			shape.move(p);
		}
	}

	public void registerObserver(MyObserver observer)
	{
		// TODO Auto-generated method stub
		for(Shape shape:unit)
		{
			shape.registerObserver(observer);
		}
	}

	public void save(String filename, int num)
	{
		// TODO Auto-generated method stub
		for(Shape shape:unit)
		{
			shape.save(filename, num);
		}
	}

	public void setColor(Color color, String colorName)
	{
		// TODO Auto-generated method stub
		for(Shape shape:unit)
		{
			shape.setColor(color, colorName);
		}
	}

	public void contain(Shape shape )
	{
		unit.add(shape);
	}

	public void setState(boolean state)
	{
		// TODO Auto-generated method stub
		
	}

	public ArrayList out()
	{
		return unit;
	}

	public String getDescrption()
	{
		String result="";
		// TODO Auto-generated method stub
		for(Shape shape:unit)
		{
			result+=shape.getDescrption();
		}
		return result;
	}

	public Point getLRpoint()
	{
		// TODO Auto-generated method stub
		return this.ULpoint;
	}

	public Point getULpoint()
	{
		// TODO Auto-generated method stub
		return this.lrpoint;
	}
	
}

⌨️ 快捷键说明

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