mirror of
https://github.com/dmolony/DiskBrowser.git
synced 2024-11-26 23:51:57 +00:00
global format
This commit is contained in:
parent
95d3930c53
commit
f4560ec130
@ -9,7 +9,7 @@ class Cell implements Comparable<Cell>, Value
|
||||
final Address address;
|
||||
private final Sheet parent;
|
||||
private CellType type;
|
||||
private char format = ' ';
|
||||
private char cellFormat = ' ';
|
||||
|
||||
private char repeatingChar;
|
||||
private String repeat = "";
|
||||
@ -41,7 +41,7 @@ class Cell implements Comparable<Cell>, Value
|
||||
// /F* - graph (histogram)
|
||||
|
||||
if (format.startsWith ("/F"))
|
||||
this.format = format.charAt (2);
|
||||
this.cellFormat = format.charAt (2);
|
||||
else if (format.startsWith ("/-"))
|
||||
{
|
||||
repeatingChar = format.charAt (2);
|
||||
@ -118,6 +118,8 @@ class Cell implements Comparable<Cell>, Value
|
||||
|
||||
case VALUE:
|
||||
if (hasValue ())
|
||||
{
|
||||
char format = cellFormat != ' ' ? cellFormat : defaultFormat;
|
||||
if (format == 'I')
|
||||
{
|
||||
String integerFormat = String.format ("%%%d.0f", colWidth);
|
||||
@ -147,13 +149,14 @@ class Cell implements Comparable<Cell>, Value
|
||||
val = val.substring (val.length () - colWidth);
|
||||
return val;
|
||||
}
|
||||
}
|
||||
}
|
||||
return getError ();
|
||||
}
|
||||
|
||||
private String justify (String text, int colWidth)
|
||||
{
|
||||
if (format == 'R')
|
||||
if (cellFormat == 'R')
|
||||
{
|
||||
String labelFormat = String.format ("%%%d.%ds", colWidth, colWidth);
|
||||
return (String.format (labelFormat, text));
|
||||
|
15
src/com/bytezone/diskbrowser/visicalc/Pi.java
Normal file
15
src/com/bytezone/diskbrowser/visicalc/Pi.java
Normal file
@ -0,0 +1,15 @@
|
||||
package com.bytezone.diskbrowser.visicalc;
|
||||
|
||||
class Pi extends Function
|
||||
{
|
||||
Pi (Sheet parent, String text)
|
||||
{
|
||||
super (parent, text);
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getValue ()
|
||||
{
|
||||
return 3.14159265;
|
||||
}
|
||||
}
|
@ -200,6 +200,12 @@ public class Sheet implements Iterable<Cell>
|
||||
case 'C':
|
||||
columnWidth = Integer.parseInt (line.substring (3));
|
||||
break;
|
||||
case 'F':
|
||||
defaultFormat = line.charAt (3);
|
||||
break;
|
||||
default:
|
||||
System.out.printf ("Unknown global format [%s]%n", line);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case 'X':
|
||||
@ -249,7 +255,7 @@ public class Sheet implements Iterable<Cell>
|
||||
|
||||
assert currentCell != null;
|
||||
|
||||
if (line.startsWith ("/G")) // global column widths
|
||||
if (line.startsWith ("/G")) // global column widths
|
||||
{
|
||||
if (line.charAt (2) == 'C' && line.charAt (3) == 'C')
|
||||
{
|
||||
@ -267,13 +273,20 @@ public class Sheet implements Iterable<Cell>
|
||||
while (line.startsWith ("/"))
|
||||
{
|
||||
String fmt = line.substring (0, 3);
|
||||
currentCell.format (fmt); // formatting command
|
||||
|
||||
if (fmt.equals ("/TH") || fmt.equals ("/TV")) // lock titles ??
|
||||
{
|
||||
// ignore
|
||||
}
|
||||
else
|
||||
currentCell.format (fmt); // formatting command
|
||||
|
||||
line = line.substring (3);
|
||||
format += fmt;
|
||||
}
|
||||
|
||||
if (!line.isEmpty ())
|
||||
currentCell.setValue (line); // expression
|
||||
currentCell.setValue (line); // expression
|
||||
|
||||
if (false)
|
||||
System.out.printf ("[%s][%-3s][%s]%n", currentCell.address, format, line);
|
||||
|
Loading…
Reference in New Issue
Block a user