protected void attachToHost() {
		if (host == null)
			return;
		if (host instanceof Particle || host instanceof RectangularObstacle) {
			switch (getAttachmentPosition()) {
			case CENTER:
				setLocation(host.getRx(), host.getRy());
				break;
			case ENDPOINT1:
				float length = (float) getLength();
				float invLength = 1.0f / length;
				float cos = (getX1() - getX2()) * invLength;
				float sin = (getY1() - getY2()) * invLength;
				setLocation(host.getRx() - length * cos * 0.5f, host.getRy() - length * sin * 0.5f);
				break;
			case ENDPOINT2:
				length = (float) getLength();
				invLength = 1.0f / length;
				cos = (getX2() - getX1()) * invLength;
				sin = (getY2() - getY1()) * invLength;
				setLocation(host.getRx() - length * cos * 0.5f, host.getRy() - length * sin * 0.5f);
				break;
			}
		}
		else if (host instanceof RadialBond) {
			RadialBond bond = (RadialBond) host;
			double length = bond.getLength(-1);
			double invLength = 0.5 / length;
			double cos = (bond.atom2.rx - bond.atom1.rx) * invLength;
			double sin = (bond.atom2.ry - bond.atom1.ry) * invLength;
			setX1((float) (bond.atom1.rx - bond.atom1.sigma * cos));
			setY1((float) (bond.atom1.ry - bond.atom1.sigma * sin));
			setX2((float) (bond.atom2.rx + bond.atom2.sigma * cos));
			setY2((float) (bond.atom2.ry + bond.atom2.sigma * sin));
		}
	}