/*
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License as
 * published by the Free Software Foundation; either version 2 of the
 * License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOUSE. See the GNU
 * General Public License for more details.
 *
 * You should have recieved a copy of the GNU General Public License
 * along with this program; if not write to the Free Software
 * Foundation, inc., 59 Temple Place, Suite 330, Boston MA 02111-1307
 * USA
 */
package j3d;
import java.awt.*;
import java.awt.geom.*;
/**
 * Insert the type's description here.
 *
 * @author: Yuriy Mikhaylovskiy
 */

public class shpLine extends Line2D.Double implements shp{
  private float sx1,sx2,sy1,sy2,sz1,sz2;
  private Color cl;
  private float z_sort;
  private boolean show;
  
  public void paint(Graphics2D g, Canvas3D j3d){
    g.setColor(cl);
    g.draw(this);
  }

//  public Color get_Color(){return cl;}
//  public Paint get_ColorFill(){return null;}

  public shpLine(float x1, float y1, float z1, float x2, float y2, float z2, Color c){
    sx1=x1;
    sx2=x2;
    sy1=y1;
    sy2=y2;
    sz1=z1;
    sz2=z2;
    cl=c;
  }
  
  public void transform2D(Matrix3D t, Vector3D cor){
    sx1 += cor.x;  
    sx2 += cor.x;  
    sy1 += cor.y;  
    sy2 += cor.y;  
    sz1 += cor.z;  
    sz2 += cor.z;  
      
    x1=sx1*t.xx+sy1*t.xy+sz1*t.xz+t.xo;
    x2=sx2*t.xx+sy2*t.xy+sz2*t.xz+t.xo;
    y1=sx1*t.yx+sy1*t.yy+sz1*t.yz+t.yo;
    y2=sx2*t.yx+sy2*t.yy+sz2*t.yz+t.yo;
    z_sort =((sx1+sx2)*t.zx+(sy1+sy2)*t.zy+(sz1+sz2)*t.zz)/2+t.zo;

    sx1 -= cor.x;  
    sx2 -= cor.x;  
    sy1 -= cor.y;  
    sy2 -= cor.y;  
    sz1 -= cor.z;  
    sz2 -= cor.z;  
  }

  public float get_Z(){
    return z_sort;
  }
  
  public boolean isPickPoint(int x, int y) {

      if (ptSegDistSq((double)x, (double)y) <= Canvas3D.PICKDISTANCE) return true;
      
      return false;
      
  }

public boolean isPickPoint(Rectangle2D r) {

      if (r.contains(this.getBounds())) return true;
      
      return false;
      
  }  
public void setShow(boolean s) {
    show = s;
}

public boolean isShow() {
    return show;
}
  
}