public void update(Graphics g) {
		if (offsetPaint==null) offsetPaint=createImage(257, 257);
		if (toRefresh) {
			g.clearRect(0, 0, 600, 600);
			toRefresh = false;
		}
		Graphics g2 = offsetPaint.getGraphics();
		g2.clearRect(0, 0, 600, 600);
		if (image!=null) {
			g2.drawImage( image, 0, 0, null);
			if (tileset) {
				g2.setColor(new Color(255, 0, 0));
				int w=0, width=0, height=0, x=-1, y=-1;
				if (tileSelected.size()>1) {
					for (int v : tileSelected) {
						if (v==-1) {
							if(w!=0) {
								width=w;
								height++;
							}
						w=0;
						} else {
							if (x==-1)
								x=v%(image.getWidth()/(8*zoom));
							if (y==-1)
								y=v/+(image.getWidth()/(8*zoom));
							w++;
							if (w >= image.getWidth()/(8*zoom))  {
								height++;
								width = w;
								w=0;
							}
						}
					}
					if ((x+width)>image.getWidth()/(8*zoom))
						width = (image.getWidth()/(8*zoom))-x;
					if ((y+height)>image.getHeight()/(8*zoom))
						height = (image.getHeight()/(8*zoom))-y;
				} else if (tileSelected.size()==1) {
					width=1;height=1;
					x=tileSelected.get(0) %(image.getWidth()/(8*zoom));
					y=tileSelected.get(0) /(image.getWidth()/(8*zoom));
				}
				g2.drawRect(x*(8*zoom), y*(8*zoom), width*(8*zoom), height*(8*zoom));
			}
		}
		paint(g);
	}