mirror of
https://github.com/dmolony/DiskBrowser.git
synced 2025-02-16 23:30:52 +00:00
tuning
This commit is contained in:
parent
845117bf2d
commit
14c6e4e3cc
@ -2,26 +2,45 @@ package com.bytezone.diskbrowser.visicalc;
|
||||
|
||||
public class Max extends Function
|
||||
{
|
||||
Range range;
|
||||
private final Range range;
|
||||
private boolean hasChecked;
|
||||
private double max = Double.MIN_VALUE;
|
||||
|
||||
public Max (Sheet parent, String text)
|
||||
{
|
||||
super (parent, text);
|
||||
|
||||
range = getRange (text);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasValue ()
|
||||
{
|
||||
if (!hasChecked)
|
||||
calculate ();
|
||||
return hasValue;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getValue ()
|
||||
{
|
||||
double max = Double.MIN_VALUE;
|
||||
for (Address address : range)
|
||||
{
|
||||
double value = parent.getCell (address).getValue ();
|
||||
if (value > max)
|
||||
max = value;
|
||||
}
|
||||
return max;
|
||||
if (!hasChecked)
|
||||
calculate ();
|
||||
return hasValue ? max : 0;
|
||||
}
|
||||
|
||||
private void calculate ()
|
||||
{
|
||||
hasChecked = true;
|
||||
for (Address address : range)
|
||||
{
|
||||
Cell cell = parent.getCell (address);
|
||||
if (cell != null && cell.hasValue ())
|
||||
{
|
||||
hasValue = true;
|
||||
double value = cell.getValue ();
|
||||
if (value > max)
|
||||
max = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -2,25 +2,45 @@ package com.bytezone.diskbrowser.visicalc;
|
||||
|
||||
public class Min extends Function
|
||||
{
|
||||
Range range;
|
||||
private final Range range;
|
||||
private boolean hasChecked;
|
||||
private double min = Double.MAX_VALUE;
|
||||
|
||||
public Min (Sheet parent, String text)
|
||||
{
|
||||
super (parent, text);
|
||||
|
||||
range = getRange (text);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasValue ()
|
||||
{
|
||||
if (!hasChecked)
|
||||
calculate ();
|
||||
return hasValue;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getValue ()
|
||||
{
|
||||
double min = Double.MAX_VALUE;
|
||||
if (!hasChecked)
|
||||
calculate ();
|
||||
return hasValue ? min : 0;
|
||||
}
|
||||
|
||||
private void calculate ()
|
||||
{
|
||||
hasChecked = true;
|
||||
for (Address address : range)
|
||||
{
|
||||
double value = parent.getCell (address).getValue ();
|
||||
if (value < min)
|
||||
min = value;
|
||||
Cell cell = parent.getCell (address);
|
||||
if (cell != null && cell.hasValue ())
|
||||
{
|
||||
hasValue = true;
|
||||
double value = cell.getValue ();
|
||||
if (value < min)
|
||||
min = value;
|
||||
}
|
||||
}
|
||||
return min;
|
||||
}
|
||||
}
|
@ -299,8 +299,8 @@ public class Sheet implements Iterable<Cell>
|
||||
Cell getCell (Address address)
|
||||
{
|
||||
Cell cell = sheet.get (address.sortValue);
|
||||
if (cell == null)
|
||||
System.out.printf ("Nonexistent cell requested [%s]%n", address);
|
||||
// if (cell == null)
|
||||
// System.out.printf ("Nonexistent cell requested [%s]%n", address);
|
||||
|
||||
return cell;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user