fr.noop.subtitle.base.BaseSubtitleCue Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of subtitle Show documentation
Show all versions of subtitle Show documentation
Convert subtitles from one format to another format.
Supported formats: STL EBU, TTML SMI, VTT, SRT, STT XML, ASS
/*
* This file is part of the noOp organization .
*
* (c) Cyrille Lebeaupin
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
*/
package fr.noop.subtitle.base;
/**
* Created by clebeaupin on 09/10/15.
*/
import fr.noop.subtitle.model.SubtitleCue;
import fr.noop.subtitle.model.SubtitleLine;
import fr.noop.subtitle.util.SubtitleTextLine;
import fr.noop.subtitle.util.SubtitleTimeCode;
import java.util.ArrayList;
import java.util.List;
public abstract class BaseSubtitleCue implements SubtitleCue {
private String id; // Id of cue. 1 or c1
private SubtitleTimeCode startTime; // Start displaying the cue at this time code
private SubtitleTimeCode endTime; // Stop displaying the cue at this time code
private List lines; // Lines composed of texts
private String characterCodes; // Character codes of subtitle text
protected BaseSubtitleCue(SubtitleCue cue) {
this.id = cue.getId();
this.startTime = cue.getStartTime();
this.endTime = cue.getEndTime();
this.lines = new ArrayList<>(cue.getLines());
}
protected BaseSubtitleCue() {
this.lines = new ArrayList<>();
}
protected BaseSubtitleCue(SubtitleTimeCode startTime, SubtitleTimeCode endTime) {
this.lines = new ArrayList<>();
this.startTime = startTime;
this.endTime = endTime;
}
protected BaseSubtitleCue(SubtitleTimeCode startTime, SubtitleTimeCode endTime, List lines) {
this.startTime = startTime;
this.endTime = endTime;
this.lines = lines;
}
public String getId() {
return this.id;
}
public void setId(String id) {
this.id = id;
}
public SubtitleTimeCode getStartTime() {
return this.startTime;
}
public void setStartTime(SubtitleTimeCode startTime) {
this.startTime = startTime;
}
public SubtitleTimeCode getEndTime() {
return this.endTime;
}
public void setEndTime(SubtitleTimeCode endTime) {
this.endTime = endTime;
}
public List getLines() {
return this.lines;
}
public void setLines(List lines) {
this.lines = lines;
}
public void addLine(SubtitleLine line) {
this.lines.add(line);
}
public void subtractTime(SubtitleTimeCode toSubtract) {
this.setStartTime(this.getStartTime().subtract(toSubtract));
this.setEndTime(this.getEndTime().subtract(toSubtract));
}
public String getText() {
String[] texts = new String[this.lines.size()];
for (int i=0; i
© 2015 - 2025 Weber Informatics LLC | Privacy Policy