001: /*
002: * Copyright 2006-2007 Pentaho Corporation. All rights reserved.
003: * This software was developed by Pentaho Corporation and is provided under the terms
004: * of the Mozilla Public License, Version 1.1, or any later version. You may not use
005: * this file except in compliance with the license. If you need a copy of the license,
006: * please go to http://www.mozilla.org/MPL/MPL-1.1.txt.
007: *
008: * Software distributed under the Mozilla Public License is distributed on an "AS IS"
009: * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. Please refer to
010: * the license for the specific language governing your rights and limitations.
011: *
012: * Additional Contributor(s): Martin Schmid gridvision engineering GmbH
013: */
014: package org.pentaho.reportdesigner.crm.report.lineal;
015:
016: import org.jetbrains.annotations.NotNull;
017: import org.pentaho.reportdesigner.crm.report.Unit;
018:
019: /**
020: * User: Martin
021: * Date: 07.02.2006
022: * Time: 20:48:40
023: */
024: public class NumberHelper {
025: private NumberHelper() {
026: }
027:
028: public static double getFactorForUnitAndScale(@NotNull
029: Unit unit, double sf) {
030: switch (unit) {
031: case POINTS: {
032: if (sf < 0.2) {
033: return 200;
034: } else if (sf < 0.5) {
035: return 100;
036: } else if (sf < 2) {
037: return 50;
038: } else if (sf < 3) {
039: return 20;
040: } else {
041: return 10;
042: }
043: }
044: case INCH: {
045: if (sf < 0.2) {
046: return 2;
047: } else if (sf < 0.5) {
048: return 1;
049: } else if (sf < 2) {
050: return 0.5;
051: } else if (sf < 3) {
052: return 0.2;
053: } else {
054: return 0.1;
055: }
056: }
057: case CM: {
058: if (sf < 0.2) {
059: return 5;
060: } else if (sf < 0.5) {
061: return 2;
062: } else if (sf < 2) {
063: return 1;
064: } else if (sf < 4) {
065: return 0.5;
066: } else {
067: return 0.2;
068: }
069: }
070: case MM: {
071: if (sf < 0.5) {
072: return 50;
073: } else if (sf < 1) {
074: return 20;
075: } else if (sf < 3) {
076: return 10;
077: } else if (sf < 4) {
078: return 5;
079: } else {
080: return 2;
081: }
082: }
083: case PICA: {
084: if (sf < 0.2) {
085: return 20;
086: } else if (sf < 0.5) {
087: return 10;
088: } else if (sf < 2) {
089: return 5;
090: } else if (sf < 3) {
091: return 2;
092: } else {
093: return 1;
094: }
095: }
096: }
097:
098: return 1;
099: }
100: }
|