1 /* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 package org
.libreoffice
;
11 import android
.graphics
.Rect
;
12 import android
.graphics
.RectF
;
14 import org
.mozilla
.gecko
.gfx
.IntSize
;
17 * Identifies the tile by its position (x and y coordinate on the document), zoom and tile size (currently static)
19 public class TileIdentifier
{
22 public final float zoom
;
23 public final IntSize size
;
25 public TileIdentifier(int x
, int y
, float zoom
, IntSize size
) {
33 * Returns a rectangle of the tiles position in scaled coordinates.
35 public RectF
getRectF() {
36 return new RectF(x
, y
, x
+ size
.width
, y
+ size
.height
);
40 * Returns a rectangle of the tiles position in non-scaled coordinates (coordinates as the zoom would be 1).
42 public RectF
getCSSRectF() {
43 float cssX
= x
/ zoom
;
44 float cssY
= y
/ zoom
;
45 float cssSizeW
= size
.width
/ zoom
;
46 float cssSizeH
= size
.height
/ zoom
;
47 return new RectF(cssX
, cssY
, cssX
+ cssSizeW
, cssY
+ cssSizeH
);
51 * Returns an integer rectangle of the tiles position in non-scaled and rounded coordinates (coordinates as the zoom would be 1).
53 public Rect
getCSSRect() {
54 float cssX
= x
/ zoom
;
55 float cssY
= y
/ zoom
;
56 float sizeW
= size
.width
/ zoom
;
57 float sizeH
= size
.height
/ zoom
;
59 (int) cssX
, (int) cssY
,
61 (int) (cssY
+ sizeH
) );
65 public boolean equals(Object o
) {
66 if (this == o
) return true;
67 if (o
== null || getClass() != o
.getClass()) return false;
69 TileIdentifier that
= (TileIdentifier
) o
;
71 if (x
!= that
.x
) return false;
72 if (y
!= that
.y
) return false;
73 if (Float
.compare(that
.zoom
, zoom
) != 0) return false;
79 public int hashCode() {
81 result
= 31 * result
+ y
;
82 result
= 31 * result
+ (zoom
!= +0.0f ? Float
.floatToIntBits(zoom
) : 0);
87 public String
toString() {
88 return String
.format("TileIdentifier (%d, %d) z=%f s=(%d, %d)", x
, y
, zoom
, size
.width
, size
.height
);
92 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */