package presentation;
import java.util.Collection;
import java.util.List;
/**
* A Topic is the most important unit of the content of a presentation
* and is identified by a name and (usually) a number. Topics are
* related to each other in a tree structure.
*
* A Topic's name and any associated content appear
* entirely on one slide of the presentation.
*/
abstract class Topic {
/** Name displayed in the slide. */
FormattedText name;
/** Plain-text name displayed in the outline. */
String outlineName;
/** Topic number. */
String number;
/** Content associated with the topic. */
List content;
/** Child topics, forming a tree structure. */
List children;
/** Topic that has this as a child. */
Topic parent;
/** Slide that contains this topic. */
Slide slide;
/**
* True if the topic's content and subtopics are initially
* collapsed but can be expanded inside the slide.
*/
boolean expandable;
/** Whether an 'expandable' topic is expanded inside the slide. */
boolean expandedInSlide;
/** Whether a topic is expanded within the outline navigator. */
boolean expandedInOutline;
/**
* Expands the current topic in the outline.
*/
/*@
requires
//
//The topic is currently collapsed
//
(expandedInOutline == false);
ensures
//
//If the topic is expandable and not already expanded, it gets expanded in the outline
//
(expandedInOutline == true);
*/
abstract void expand();
/**
* Collapses the current topic in the outline.
*/
/*@
requires
//
//The topic is already expanded
//
(expandedInOutline == true);
ensures
//
//If the topic is expandable and already expanded, it gets collapsed in the outline
//
(expandedInOutline == false);
*/
abstract void collapse();
/**
* Inserts a topic as a sibling of this topic.
*/
/*@
ensures
// The topic's parent has the new topic as a new child,
// immediately following the current topic.
(\exists int i; parent.children.get(i) == this && parent.children.get(i+1) == newTopic
&& (\forall int j; (j >= 0 && j < i) || (j > i+1 && j < parent.children.size());
parent.children.get(i) == \old(parent.children).get(i)));
*/
abstract void addSiblingTopic(Topic newTopic);
/**
* Inserts a topic as the last child of this topic.
*/
/*@
ensures
// The new topic is the first child
(newTopic == children.get(children.size() - 1))
&&
// All other topics are unchanged
(children.size() == \old(children).size() - 1)
&&
(\forall int i; i < \old(children).size(); children.get(i) == \old(children).get(i));
*/
abstract void addSubTopic(Topic newTopic);
/**
* Inserts content to be associated with this topic, after all
* existing associated content.
*/
abstract void addContent(ContentElement content);
}
/**
* ContentElements are optionally attached to topics to provide
* richer and more detailed exposition.
*/
abstract class ContentElement {}
/**
* A paragraph inserted into the presentation.
*/
class Paragraph extends ContentElement {
FormattedText content;
}
/**
* An image inserted into the presentation. Contains dimensions
* of the image plus some representation of the image data.
*/
class Image extends ContentElement {
int width;
int height;
/* */
}
/**
* Text including bold and italic portions.
*/
class FormattedText { /* */ }