/* $Id: PolygonalLineActionListener.java 236 2011-06-23 15:18:05Z shayashi $ */
package smart_gs.swingui.toolbar.action;

import java.awt.Frame;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JOptionPane;

import smart_gs.drawing_tool.ImageLabel;
import smart_gs.drawing_tool.drawing_mode.BrokenLineMode;
import smart_gs.drawing_tool.drawing_mode.DefaultDrawingMode;
import smart_gs.drawing_tool.state.DefaultState;
import smart_gs.swingui.LineSegmentsEditingFrame;

public class PolygonalLineActionListener implements ActionListener{
	//20080716 shimizu wrote
	/*
	 * ラインが非表示でも切り出しできる問題を修正
	 */
	public void actionPerformed(ActionEvent e) {
		if(LineSegmentsEditingFrame.isPolygonalLineSelect()){
			LineSegmentsEditingFrame.polygonalLineClaer();
			DefaultState.getInstance().setMode(DefaultDrawingMode.getInstance());
			return;
		}
		if(ImageLabel.isLineShown()){
			DefaultState.getInstance().setMode(BrokenLineMode.getInstance());
		}else{
			int answer = JOptionPane.showConfirmDialog(new Frame(), "Please execute it after pushing \"ShowLine\".","Information",JOptionPane.DEFAULT_OPTION);
			if (answer == JOptionPane.OK_OPTION) {
			}
			LineSegmentsEditingFrame.polygonalLineClaer();
		}
	}
}
