Skip to content

hatemile/hatemile-for-java

Repository files navigation

HaTeMiLe for Java

HaTeMiLe (HTML Accessible) is a library that can convert a HTML code in a HTML code more accessible.

Accessibility solutions

Documentation

To generate the full API documentation of HaTeMiLe of Java:

  1. Install Maven;
  2. Execute the command mvn site in HaTeMiLe of Java directory.

Import the library to your project

Maven

Step 1. Add the JitPack repository to your build file

    <repositories>
        <repository>
            <id>jitpack.io</id>
            <url>https://jitpack.io</url>
        </repository>
    </repositories>

Step 2. Add the dependency

    <dependency>
        <groupId>com.github.hatemile</groupId>
        <artifactId>hatemile-for-java</artifactId>
        <version>2.2.0</version>
    </dependency>

Gradle

Step 1. Add it in your root build.gradle at the end of repositories

    allprojects {
        repositories {
            ...
            maven { url 'https://jitpack.io' }
        }
    }

Step 2. Add the dependency

    dependencies {
            compile 'com.github.hatemile:hatemile-for-java:2.2.0'
    }

sbt

Step 1. Add it in your build.sbt at the end of resolvers

    resolvers += "jitpack" at "https://jitpack.io"

Step 2. Add the dependency

    libraryDependencies += "com.github.hatemile" % "hatemile-for-java" % "2.2.0"

Leiningen

Step 1. Add it in your project.clj at the end of repositories

    :repositories [["jitpack" "https://jitpack.io"]]

Step 2. Add the dependency

    :dependencies [[com.github.hatemile/hatemile-for-java "2.2.0"]]

Usage

Import all needed classes:

import org.hatemile.AccessibleAssociation;
import org.hatemile.AccessibleCSS;
import org.hatemile.AccessibleDisplay;
import org.hatemile.AccessibleEvent;
import org.hatemile.AccessibleForm;
import org.hatemile.AccessibleNavigation;
import org.hatemile.implementation.AccessibleAssociationImplementation;
import org.hatemile.implementation.AccessibleCSSImplementation;
import org.hatemile.implementation.AccessibleDisplayScreenReaderImplementation;
import org.hatemile.implementation.AccessibleEventImplementation;
import org.hatemile.implementation.AccessibleFormImplementation;
import org.hatemile.implementation.AccessibleNavigationImplementation;
import org.hatemile.util.Configure;
import org.hatemile.util.css.StyleSheetParser;
import org.hatemile.util.css.phcss.PHCSSParser;
import org.hatemile.util.html.HTMLDOMParser;
import org.hatemile.util.html.jsoup.JsoupHTMLDOMParser;

Instanciate the configuration, the parsers and solution classes and execute them:

//Configure
Configure configure = new Configure();
//Parsers
HTMLDOMParser htmlParser = new JsoupHTMLDOMParser(htmlCode);
StyleSheetParser cssParser = new PHCSSParser(htmlParser, currentURL);
//Execute
AccessibleAssociation accessibleAssociation =
        new AccessibleAssociationImplementation(htmlParser, configure);
accessibleAssociation.associateAllDataCellsWithHeaderCells();
accessibleAssociation.associateAllLabelsWithFields();

AccessibleCSS accessibleCSS =
        new AccessibleCSSImplementation(htmlParser, cssParser, configure);
accessibleCSS.provideAllSpeakProperties();

AccessibleDisplay accessibleDisplay =
        new AccessibleDisplayScreenReaderImplementation(htmlParser, configure);
accessibleDisplay.displayAllAlternativeTextImages();
accessibleDisplay.displayAllCellHeaders();
accessibleDisplay.displayAllDragsAndDrops();
accessibleDisplay.displayAllLanguages();
accessibleDisplay.displayAllLinksAttributes();
accessibleDisplay.displayAllRoles();
accessibleDisplay.displayAllShortcuts();
accessibleDisplay.displayAllTitles();
accessibleDisplay.displayAllWAIARIAStates();

AccessibleEvent accessibleEvent =
        new AccessibleEventImplementation(htmlParser, configure);
accessibleEvent.makeAccessibleAllClickEvents();
accessibleEvent.makeAccessibleAllDragandDropEvents();
accessibleEvent.makeAccessibleAllHoverEvents();

AccessibleForm accessibleForm =
        new AccessibleFormImplementation(htmlParser, configure);
accessibleForm.markAllAutoCompleteFields();
accessibleForm.markAllInvalidFields();
accessibleForm.markAllRangeFields();
accessibleForm.markAllRequiredFields();

AccessibleNavigation accessibleNavigation =
        new AccessibleNavigationImplementation(htmlParser, configure);
accessibleNavigation.provideNavigationByAllHeadings();
accessibleNavigation.provideNavigationByAllSkippers();
accessibleNavigation.provideNavigationToAllLongDescriptions();

accessibleDisplay.displayAllShortcuts();
PrintWriter printWriter = new PrintWriter("example.html");
printWriter.println(htmlParser.getHTML());
printWriter.close();

Contributing

If you want contribute with HaTeMiLe for Java, read contributing guidelines.

See also