Skip to content

Commit

Permalink
Merge pull request #9 from SwissAS/make_jcgm_thread_safe
Browse files Browse the repository at this point in the history
JCGM is now thread safe.
  • Loading branch information
daviddiana11 authored Jul 20, 2023
2 parents 3146c62 + 94a342a commit 294f539
Show file tree
Hide file tree
Showing 110 changed files with 977 additions and 940 deletions.
2 changes: 1 addition & 1 deletion build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<project name="jcgm" default="jar">

<!-- The core package -->
<property name="version-core" value="0.4.2"/>
<property name="version-core" value="1.0.0"/>
<property name="package-name-core" value="jcgm-core-${version-core}"/>
<property name="jar-name-core" value="${package-name-core}.jar"/>
<property name="jar-name-core-sources" value="${package-name-core}-sources.jar"/>
Expand Down
6 changes: 3 additions & 3 deletions src/net/sf/jcgm/core/AlternateCharacterSetIndex.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,12 @@ public class AlternateCharacterSetIndex extends Command {

private int index;

public AlternateCharacterSetIndex(int ec, int eid, int l, DataInput in) throws IOException {
super(ec, eid, l, in);
public AlternateCharacterSetIndex(int ec, int eid, int l, DataInput in, CGM cgm) throws IOException {
super(ec, eid, l, in, cgm);

this.index = makeIndex();

unimplemented("");
unimplemented("", this.cgm);
}

@Override
Expand Down
4 changes: 2 additions & 2 deletions src/net/sf/jcgm/core/AppendText.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ public class AppendText extends Command {
*/
private boolean executed = false;

public AppendText(int ec, int eid, int l, DataInput in) throws IOException {
super(ec, eid, l, in);
public AppendText(int ec, int eid, int l, DataInput in, CGM cgm) throws IOException {
super(ec, eid, l, in, cgm);

this.finalNotFinal = makeEnum() >= 1;
this.string = makeString();
Expand Down
16 changes: 8 additions & 8 deletions src/net/sf/jcgm/core/ApplicationData.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,25 +34,25 @@ public class ApplicationData extends Command {
int identifier;
String data;

public ApplicationData(int ec, int eid, int l, DataInput in)
public ApplicationData(int ec, int eid, int l, DataInput in, CGM cgm)
throws IOException {
super(ec, eid, l, in);

identifier = makeInt();
data = makeString();
super(ec, eid, l, in, cgm);
this.identifier = makeInt();
this.data = makeString();
}

@Override
public String toString() {
return "ApplicationData: " + identifier + " " + this.data;
return "ApplicationData: " + this.identifier + " " + this.data;
}

public int getIdentifier() {
return identifier;
return this.identifier;
}

public String getData() {
return data;
return this.data;
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/net/sf/jcgm/core/ApplicationStructureAttribute.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ public class ApplicationStructureAttribute extends Command {
private final String applicationStructureAttributeType;
private final StructuredDataRecord sdr;

public ApplicationStructureAttribute(int ec, int eid, int l, DataInput in) throws IOException {
super(ec, eid, l, in);
public ApplicationStructureAttribute(int ec, int eid, int l, DataInput in, CGM cgm) throws IOException {
super(ec, eid, l, in, cgm);

// application structure attribute type (SF)
this.applicationStructureAttributeType = makeString();
Expand Down
4 changes: 2 additions & 2 deletions src/net/sf/jcgm/core/BackgroundColour.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@
public class BackgroundColour extends Command {
private final Color backgroundColor;

public BackgroundColour(int ec, int eid, int l, DataInput in)
public BackgroundColour(int ec, int eid, int l, DataInput in, CGM cgm)
throws IOException {
super(ec, eid, l, in);
super(ec, eid, l, in, cgm);

this.backgroundColor = makeDirectColor();

Expand Down
4 changes: 2 additions & 2 deletions src/net/sf/jcgm/core/BeginApplicationStructure.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ public class BeginApplicationStructure extends Command {
private final String applicationStructureType;
private final boolean inheritanceFlag;

public BeginApplicationStructure(int ec, int eid, int l, DataInput in) throws IOException {
super(ec, eid, l, in);
public BeginApplicationStructure(int ec, int eid, int l, DataInput in, CGM cgm) throws IOException {
super(ec, eid, l, in, cgm);

// application structure identifier (SF)
this.applicationStructureIdentifier = makeString();
Expand Down
4 changes: 2 additions & 2 deletions src/net/sf/jcgm/core/BeginApplicationStructureBody.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@
* @version $Id$
*/
public class BeginApplicationStructureBody extends Command {
BeginApplicationStructureBody(int ec, int eid, int l, DataInput in)
BeginApplicationStructureBody(int ec, int eid, int l, DataInput in, CGM cgm)
throws IOException {
super(ec, eid, l, in);
super(ec, eid, l, in, cgm);
// no arguments

// make sure all the arguments were read
Expand Down
4 changes: 2 additions & 2 deletions src/net/sf/jcgm/core/BeginMetafile.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@
public class BeginMetafile extends Command {
private final String fileName;

public BeginMetafile(int ec, int eid, int l, DataInput in)
public BeginMetafile(int ec, int eid, int l, DataInput in, CGM cgm)
throws IOException {
super(ec, eid, l, in);
super(ec, eid, l, in, cgm);
this.fileName = l > 0 ? makeString() : "";

// make sure all the arguments were read
Expand Down
6 changes: 3 additions & 3 deletions src/net/sf/jcgm/core/BeginPicture.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@
public class BeginPicture extends Command {
String S;

public BeginPicture(int ec, int eid, int l, DataInput in)
public BeginPicture(int ec, int eid, int l, DataInput in, CGM cgm)
throws IOException {
super(ec, eid, l, in);
super(ec, eid, l, in, cgm);
this.S = l > 0 ? makeString() : "";

// make sure all the arguments were read
Expand All @@ -48,7 +48,7 @@ public String toString() {
}

public String getPictureName() {
return S;
return this.S;
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/net/sf/jcgm/core/BeginPictureBody.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@
* @version $Id$
*/
public class BeginPictureBody extends Command {
public BeginPictureBody(int ec, int eid, int l, DataInput in)
public BeginPictureBody(int ec, int eid, int l, DataInput in, CGM cgm)
throws IOException {
super(ec, eid, l, in);
super(ec, eid, l, in, cgm);
// no arguments

// make sure all the arguments were read
Expand Down
6 changes: 3 additions & 3 deletions src/net/sf/jcgm/core/BeginTileArray.java
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ public class BeginTileArray extends Command {
private final int nCellsInPathDirection;
private final int nCellsInLineDirection;

BeginTileArray(int ec, int eid, int l, DataInput in) throws IOException {
super(ec, eid, l, in);
BeginTileArray(int ec, int eid, int l, DataInput in, CGM cgm) throws IOException {
super(ec, eid, l, in, cgm);

this.position = makePoint();
this.cellPathDirection = makeEnum();
Expand Down Expand Up @@ -99,7 +99,7 @@ public void paint(CGMDisplay d) {
- (this.nTilesInLineDirection - 1) * this.nCellsPerTileInLineDirection;

if (amountOfLastLineCellsInLineDirection != this.nCellsPerTileInLineDirection) {
Messages.getInstance().add(new Message(Message.Severity.INFO, getElementClass(), getElementCode(),
d.getCGM().addMessage(new Message(Message.Severity.INFO, getElementClass(), getElementCode(),
"the amount of cells of the last line is different than the given amount of cells per line", toString()));
}

Expand Down
17 changes: 9 additions & 8 deletions src/net/sf/jcgm/core/BitonalTile.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,23 +44,24 @@ public class BitonalTile extends TileElement {
private Color foregroundColor = null;
private int foregroundColorIndex;

BitonalTile(int ec, int eid, int l, DataInput in) throws IOException {
super(ec, eid, l, in);
BitonalTile(int ec, int eid, int l, DataInput in, CGM cgm) throws IOException {
super(ec, eid, l, in, cgm);

this.compressionType = CompressionType.get(makeIndex());
this.rowPaddingIndicator = makeInt();

if (ColourSelectionMode.getType().equals(ColourSelectionMode.Type.DIRECT)) {

final ColourSelectionMode.Type colourSelectionMode = cgm.getColourSelectionMode();
if (colourSelectionMode.equals(ColourSelectionMode.Type.DIRECT)) {
this.backgroundColor = makeDirectColor();
}
else if (ColourSelectionMode.getType().equals(ColourSelectionMode.Type.INDEXED)) {
else if (colourSelectionMode.equals(ColourSelectionMode.Type.INDEXED)) {
this.backgroundColorIndex = makeColorIndex();
}

if (ColourSelectionMode.getType().equals(ColourSelectionMode.Type.DIRECT)) {
if (colourSelectionMode.equals(ColourSelectionMode.Type.DIRECT)) {
this.foregroundColor = makeDirectColor();
}
else if (ColourSelectionMode.getType().equals(ColourSelectionMode.Type.INDEXED)) {
else if (colourSelectionMode.equals(ColourSelectionMode.Type.INDEXED)) {
this.foregroundColorIndex = makeColorIndex();
}

Expand All @@ -69,7 +70,7 @@ else if (ColourSelectionMode.getType().equals(ColourSelectionMode.Type.INDEXED))

@Override
protected void readBitmap() {
unsupported("BITMAP for BitonalTile");
unsupported("BITMAP for BitonalTile", this.cgm);
}

@Override
Expand Down
Loading

0 comments on commit 294f539

Please sign in to comment.